Python SDK
Client library for Python applications to interact with ERC-1066-x402 gateway.
Installation
Terminal
# Install Python SDK
pip install hyperkitlabs-erc1066-x402Initialization
client.py
from erc1066_x402 import ERC1066Client
# Initialize client with gateway URL
client = ERC1066Client('https://gateway.example.com')Methods
validate_intent
Validates an intent without executing it
Terminal
result = client.validate_intent(intent, chain_id)
# Returns:
{
'status': '0x01', # Status code
'http_code': 200, # HTTP status code
'intent_hash': '0x...'
}execute_intent
Executes a validated intent on-chain
Terminal
result = client.execute_intent(intent, chain_id)
# Returns execution resultmap_status_to_action
Maps status code to agent action
Terminal
action = client.map_status_to_action('0x01')
# Returns: 'execute' | 'request_payment' | 'retry' | 'deny'Examples
example.py
from erc1066_x402 import ERC1066Client, Intent
client = ERC1066Client('https://gateway.example.com')
intent = Intent(
sender='0x...',
target='0x...',
data='0x...',
value='0',
nonce='0',
policyId='0x...'
)
# Validate intent
result = client.validate_intent(intent, 133717)
# Map status to action
action = client.map_status_to_action(result['status'])
# Execute based on action
if action == 'execute':
client.execute_intent(intent, 133717)
elif action == 'request_payment':
request_payment(result['payment_url'])