Gasless Polymarket position redemption — Redeem as a Service
Project description
patly
Gasless Polymarket position redemption. $0.01 per redemption, deducted from your winnings.
import patly, os
patly.init(api_key=os.getenv("PATLY_API_KEY"), pk=os.getenv("PK"))
patly.redeem("btc-updown-15m-1774088100", "NO")
That's it.
How it works
When you call patly.redeem(), the library:
- Fetches the market's
conditionIdfrom Patly - Verifies the market is resolved on-chain
- Builds a Safe multisend transaction containing:
redeemPositions()— claims your winning USDC into your walletUSDC.transfer($0.01 → Patly)— fee, paid from your winnings
- Signs the transaction locally with your private key
- Sends only the signature to Patly — never the key
- Patly relays it through Polymarket's gasless Builder relayer
Everything is gasless (Polymarket pays gas) and atomic — the fee only goes through if the redemption succeeds.
Installation
pip install patly
Quickstart
1. Register
import requests
r = requests.post("http://patly.duckdns.org/register", json={
"wallet": "0xYourPolymarketWallet"
})
print(r.json())
# {"api_key": "...", "wallet": "0x...", "message": "Save your API key"}
2. Set env vars
PATLY_API_KEY=your_api_key_here
PK=0xyour_polymarket_wallet_private_key
3. Redeem
import patly, os
from dotenv import load_dotenv
load_dotenv()
patly.init(
api_key=os.getenv("PATLY_API_KEY"),
pk=os.getenv("PK"),
)
patly.redeem("btc-updown-15m-1774088100", "NO")
# [patly] ✅ btc-updown-15m-1774088100: 0xabc123...
API
Module-level (recommended)
import patly
patly.init(api_key="...", pk="0x...")
patly.redeem("btc-updown-15m-1774088100", "YES")
Class API
from patly import Patly
p = Patly(api_key="...", pk="0x...", url="http://patly.duckdns.org")
# Redeem a position
result = p.redeem("btc-updown-15m-1774088100", "NO")
# {"status": "redeemed", "tx_hash": "0x...", "polygonscan": "https://..."}
# Account stats
p.status()
# {"wallet": "0x...", "redeemed": 12, "pending": 0, "failed": 0}
# History
p.history(limit=20)
# [{"slug": "...", "won_side": "NO", "tx_hash": "0x...", "status": "redeemed", ...}]
Bot integration example
import patly, os, logging
from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(level=logging.INFO)
patly.init(
api_key=os.getenv("PATLY_API_KEY"),
pk=os.getenv("PK"),
)
def on_market_resolved(slug: str, won_side: str):
patly.redeem(slug, won_side)
Security
| Action | Where it happens |
|---|---|
Build redeemPositions() calldata |
Your machine |
| Build fee transfer calldata | Your machine |
| Sign Safe transaction with PK | Your machine |
| Transmit to Patly | Signature only — never the PK |
You can verify with Wireshark or Charles Proxy that no private key bytes are transmitted.
Pricing
| Registration | Free |
| Per redemption | $0.01 USDC |
| How it's paid | Bundled into your redeem tx — from winnings |
| Separate balance needed | ❌ No |
| Gas needed | ❌ No (gasless via Polymarket relayer) |
Requirements
- Python 3.10+
- A Polymarket wallet with winning positions to redeem
py_builder_relayer_client(Polymarket's Safe signing SDK)
Environment variables
| Variable | Description |
|---|---|
PATLY_API_KEY |
Your Patly API key |
PK |
Private key of your Polymarket wallet |
Service
- Network: Polygon (eip155:137)
- API: http://patly.duckdns.org
- Docs: https://patly.mintlify.app
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patly-0.2.2.tar.gz.
File metadata
- Download URL: patly-0.2.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3007f237499f7090f6e2b33d993164abf97d78995db2bfdc037513dd50be590e
|
|
| MD5 |
1ef44a27cf5fb201431978484313fc43
|
|
| BLAKE2b-256 |
29b5dac8c0af88303e9e551fdc972dbe46748099740535030f10ce01a62850c3
|
File details
Details for the file patly-0.2.2-py3-none-any.whl.
File metadata
- Download URL: patly-0.2.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
949583ffcfa4fdb1410aeb940d25d63f06dbeacf5ea90d8c0211646241d91d6f
|
|
| MD5 |
8649aba4fb9adde9e275e139da413031
|
|
| BLAKE2b-256 |
5a877a100d1eb9414a8de18fa3d57143938102e40cb5c61d5da54c967c010b37
|