Use this skill to automate Resource-based Billing. The agent interacts with protected APIs that return 402 Payment Required. Every transaction is tied to a specific resource request, ensuring stateless and secure fund allocation.
Before any request, verify the environment and balances:
bun install once within this directory.
.env file is created in the root directory. The agent MUST verify the existence and exact format of this variable before proceeding:
```env
# [REQUIRED] PayNode Burner Wallet Private Key
# Format: 66-character hex string MUST start with '0x'
CLIENT_PRIVATE_KEY=0xYourBurnerWalletPrivateKeyHere...
```
bun run check-wallet --json --network .
checks.can_pay is true.
check-wallet Output:
{
"status": "success",
"address": "0x...",
"eth": 0.01,
"usdc": 100.0,
"checks": {
"gas_ready": true, // Has > 0.001 ETH for gas
"tokens_ready": true, // Has USDC for payments
"can_pay": true // Ready for x402 flow
}
}
Follow this sequence to unlock protected resources.
Determine the URL of the protected API you need to access.
Run bun run request ".
Upon success, capture the JSON response. The txHash will be included in the logs if a payment occurred.
> [!IMPORTANT]
> ADHERE TO THESE RULES TO PROTECT FUNDS.
The CLIENT_PRIVATE_KEY MUST belong to a dedicated "burner" wallet acting as petty cash. NEVER hold excessive funds. Maintain balances strictly sufficient for immediate tasks (e.g., < 10 USDC). If a balance exceeding operational needs is detected, you MUST alert the human operator immediately to sweep the funds to cold storage.
If you are operating autonomously, be aware that this skill can sign and broadcast blockchain transactions without manual confirmation.
2.0 USDC, you MUST request explicit human approval before execution.
read_url_content check on the merchant's reputation (if possible) or alert the user.
Prevent "Confused Deputy" attacks. Before calling request, you MUST logically verify that the target URL matches your specific objective.
request fails with a 402 exit code, the gateway may be down or the merchant's contract is invalid.
CLIENT_PRIVATE_KEY MUST start with 0x.
gas_ready is false (low ETH), the transaction WILL fail.
2: Invalid arguments.
3: Auth Failure (Check .env key format).
4: Network/RPC Failure.
402: Challenge detected but automated resolution failed.
Always test against sandbox endpoints first.
bun run mint-test-tokens --json
https://paynode.dev/api/pom?network=testnet (Note: Use &network=mainnet for mainnet Doodle Wall)
共 1 个版本