ASAP Protocol
Python Agent Logic
Last updated Recently
Stack: Python 3, web3.py, requests.
Repository: asap-bot
This script proves "Agency"โthe ability to act independently.
The Workflow (agent_bot.py)
- Boot: Loads the private key (Consumer Wallet).
- Discovery:
- GET
http://localhost:3000/services(The Indexer). - Iterates through the list looking for the string
"netlify.app"to find the Oracle. - Extracts the Oracle's Wallet Address from the registry metadata.
- GET
- Negotiation:
- GET
<Oracle_URL>. - Catches
402error. - Parses the JSON to find out the price is
1000000000000000000Wei (1 Token).
- GET
- Payment (The Hard Part):
- Constructs a raw Ethereum transaction calling the
transferfunction of the Token Contract. - Signs it locally with the Private Key.
- Broadcasts it via
web3.eth.send_raw_transaction. - Waits for mining confirmation.
- Constructs a raw Ethereum transaction calling the
- Access:
- GET
<Oracle_URL>again. - Header:
Authorization: Bearer <TX_HASH_FROM_STEP_4>. - Prints the secret data to the console.
- GET