i created a new metamask wallet for Polymarket. i could use v2 clob client to trade through api
i have upgrade the SDK to:
/root/anaconda3/envs/py39/bin/pip3 install -U py_builder_relayer_client==0.0.2rc1
but when i tried redeem, it failed as below, could you please help?
if i create the RelayerClient with PROXY,
failed with txn 019e680f-676e-7c82-88b9-b623515290ac failed onchain, transaction_hash: !
relay_tx_type=RelayerTxType.PROXY,
if i create the RelayerClient with SAFE
# failed with
# File "/root/anaconda3/envs/py39/lib/python3.9/site-packages/py_builder_relayer_client/client.py", line 174,
# in _execute_safe_transactions
# raise RelayerClientException
# py_builder_relayer_client.exceptions.RelayerClientException:
# expected safe 0x6B0aeC696271DD0Ef597234ddd6df1F3e9Af53af is not deployed
relay_tx_type=RelayerTxType.SAFE,
my code is as below,
CTF_CONTRACT = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
USDC_CONTRACT = "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"
NEG_RISK_ADAPTER = "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"
rpc_url = 'https://polygon.drpc.org'
w3 = Web3(Web3.HTTPProvider(rpc_url))
w3.eth.default_account = w3.eth.account.from_key(config['api']['key']).address
w3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)
client = RelayClient(
relayer_url="https://relayer-v2.polymarket.com",
chain_id=137,
# relayer_url="https://relayer-v2-staging.polymarket.dev",
# chain_id=80002,
private_key=CONFIG["PRIVATE_KEY"],
builder_config=builder_config,
# failed with txn 019e680f-676e-7c82-88b9-b623515290ac failed onchain, transaction_hash: !
relay_tx_type=RelayerTxType.PROXY,
# failed with
# File "/root/anaconda3/envs/py39/lib/python3.9/site-packages/py_builder_relayer_client/client.py", line 174,
# in _execute_safe_transactions
# raise RelayerClientException
# py_builder_relayer_client.exceptions.RelayerClientException:
# expected safe 0x6B0aeC696271DD0Ef597234ddd6df1F3e9Af53af is not deployed
# relay_tx_type=RelayerTxType.SAFE,
)
def claim20260527(condition_id: str, size, is_neg_risk=False, is_redeem=False):
CTF = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
redeem_tx = Transaction(
to=CTF,
data=w3.eth.contract(
address=CTF,
abi=[{
"name": "redeemPositions",
"type": "function",
"inputs": [
{"name": "collateralToken", "type": "address"},
{"name": "parentCollectionId", "type": "bytes32"},
{"name": "conditionId", "type": "bytes32"},
{"name": "indexSets", "type": "uint256[]"}
],
"outputs": []
}]
).encode_abi(
abi_element_identifier="redeemPositions",
args=[
w3.to_checksum_address(USDC_CONTRACT),
w3.to_bytes(hexstr=HASH_ZERO),
w3.to_bytes(hexstr=condition_id),
[1, 2]
]
),
value="0",
)
response = client.execute([redeem_tx], "Redeem positions")
result = response.wait()
logger.info(result)
i created a new metamask wallet for Polymarket. i could use v2 clob client to trade through api
i have upgrade the SDK to:
/root/anaconda3/envs/py39/bin/pip3 install -U py_builder_relayer_client==0.0.2rc1but when i tried redeem, it failed as below, could you please help?
if i create the RelayerClient with PROXY,
if i create the RelayerClient with SAFE
my code is as below,