Execute Payment Intent
Overview
- Function: Execute a payment intent using the Agent wallet. The backend automatically signs and transfers USDC on Base.
- Use Cases: Automated payouts, batch payments, server-side payment processing
- Authentication: Required (Bearer token with API key and secret key)
JSON Schema Definition
{
"name": "execute_payment_intent",
"description": "Executes a payment intent using the Agent wallet. The backend signs and transfers USDC on Base automatically. Requires authentication.",
"input_schema": {
"type": "object",
"properties": {
"intent_id": {
"type": "string",
"description": "The intent ID returned from createIntent operation"
}
},
"required": ["intent_id"]
},
"output_schema": {
"type": "object",
"properties": {
"intent_id": {
"type": "string",
"description": "The intent ID"
},
"status": {
"type": "string",
"enum": ["PENDING", "SOURCE_SETTLED", "BASE_SETTLING", "BASE_SETTLED", "VERIFICATION_FAILED", "EXPIRED", "PARTIAL_SETTLEMENT"],
"description": "Current status of the intent"
},
"base_payment": {
"type": "object",
"description": "Payment receipt information (available when status is BASE_SETTLED)",
"properties": {
"tx_hash": {
"type": "string",
"description": "Transaction hash on Base chain"
},
"settle_proof": {
"type": "string",
"description": "Settlement proof"
},
"settled_at": {
"type": "string",
"description": "Settlement timestamp"
},
"explorer_url": {
"type": "string",
"description": "Block explorer URL"
}
}
}
},
"required": ["intent_id", "status"]
}
}
Parameters
Return Value
Success Response
{
"intent_id": "int_abc123xyz",
"status": "BASE_SETTLED",
"base_payment": {
"tx_hash": "0x1234...abcd",
"settle_proof": "...",
"settled_at": "2024-01-01T12:05:00Z",
"explorer_url": "https://basescan.org/tx/0x1234...abcd"
}
}
Status Values
PENDING: Execution initiated, processingSOURCE_SETTLED: Payment confirmed on the source chainBASE_SETTLING: Final settlement is being processed on the Base chainBASE_SETTLED: Transfer complete (terminal state)VERIFICATION_FAILED: Source payment verification failed (terminal state)EXPIRED: Intent was not executed within 10 minutes (terminal state)PARTIAL_SETTLEMENT: Partial amount settled on Base (terminal state)
Code Examples
TypeScript/JavaScript
import { PayClient } from '@cross402/usdc';
const client = new PayClient({
baseUrl: 'https://api-pay.agent.tech',
auth: { apiKey: 'your-api-key', secretKey: 'your-secret-key' },
});
// Execute intent
const result = await client.executeIntent(intentId);
console.log(`Intent ID: ${result.intentId}`);
console.log(`Status: ${result.status}`);
if (result.status === 'BASE_SETTLED') {
console.log(`Transaction hash: ${result.basePayment.txHash}`);
}
Go
package main
import (
"context"
"log"
"github.com/cross402/usdc-sdk-go"
)
func main() {
client, err := pay.NewClient(
"https://api-pay.agent.tech",
pay.WithBearerAuth(apiKey, secretKey),
)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// Execute intent
exec, err := client.ExecuteIntent(ctx, intentID)
if err != nil {
log.Fatal(err)
}
log.Printf("Intent ID: %s", exec.IntentID)
log.Printf("Status: %s", exec.Status)
if exec.Status == pay.StatusBaseSettled {
log.Printf("Transaction hash: %s", exec.BasePayment.TxHash)
}
}
Error Handling
Common Errors
For comprehensive error handling patterns and retry strategies, see Error Handling.
Important Notes
Authentication Required: This operation requires Bearer token authentication with valid API key and secret key.
Automatic Processing: The Agent wallet automatically handles:
- Signing the transaction
- Paying gas fees
- Transferring USDC on Base chain
Status Progression: The intent status typically progresses:
AWAITING_PAYMENT→PENDING→SOURCE_SETTLED→BASE_SETTLING→BASE_SETTLED
Terminal States: Once the status reaches
BASE_SETTLED,EXPIRED,VERIFICATION_FAILED, orPARTIAL_SETTLEMENT, it will not change.Polling: For long-running operations, use Query Intent Status to poll for status updates.
Intent Expiration: Intents expire 10 minutes after creation. Execute before expiration.
Best Practices
Error Recovery: Implement retry logic with exponential backoff for transient errors (429, 503).
Status Verification: After execution, poll the intent status to confirm completion.
Transaction Receipt: When status is
BASE_SETTLED, save the transaction hash for record-keeping.Idempotency: The operation is idempotent - safe to retry on network errors.