Local Transaction API
The Local Transaction API provides maximum security and control for x402 payments. We build the payment transaction for you, but you sign and broadcast it using your own wallet and RPC endpoint.
Overview
Base URL: https://api.yuzu402.dev
Flow:
Request a payment transaction from Yuzu402
Receive base64-encoded unsigned transaction
Sign the transaction with your wallet
Broadcast to blockchain using your RPC endpoint
Why Use Local Transactions?
Full Control: You sign and send payment transactions yourself
Custom RPC: Use your own blockchain RPC infrastructure
Maximum Security: Private keys never leave your system
Transaction Transparency: Inspect payment transactions before signing
Institutional Grade: Meets compliance requirements for payment processing
Multi-Chain Support: Works with EVM and Solana chains
Endpoints
Build Send Payment Transaction
Build an unsigned transaction for sending a payment over the x402 protocol.
Endpoint: POST /transaction/send
Request Body:
walletAddress
string
Yes
Your wallet address (EVM or Solana format)
recipientAddress
string
Yes
Payment recipient's wallet address
amount
number
Yes
Payment amount in native currency
resource
string
No
Protected resource URL being accessed
metadata
object
No
Additional payment metadata
priorityFee
number
No
Network priority fee (default: auto)
Example Request:
Success Response (200):
Build Receive Payment Transaction
Build an unsigned transaction for receiving and verifying a payment on the seller side.
Endpoint: POST /transaction/receive
Request Body:
walletAddress
string
Yes
Your receiving wallet address
paymentProof
string
Yes
Cryptographic payment proof from buyer
expectedAmount
number
Yes
Expected payment amount
resource
string
No
Protected resource being accessed
facilitatorUrl
string
No
Facilitator URL for verification
priorityFee
number
No
Network priority fee
Example Request:
Success Response (200):
Signing and Sending
After receiving the unsigned transaction, you need to sign and broadcast it.
JavaScript/TypeScript Example
Using with Wallet Adapter (Browser)
Python Example
Rust Example
Transaction Expiration
Transactions have a limited validity period:
lastValidBlockHeight: Block height after which transaction is invalid
expiresAt: Unix timestamp when transaction expires (typically 60 seconds)
Always send transactions promptly after building them.
Best Practices
Verify Transaction Contents: Inspect the transaction before signing
Use Trusted RPC: Use your own RPC or a trusted provider
Handle Expiration: Build and send transactions quickly
Confirm Transactions: Always wait for confirmation
Store Private Keys Securely: Never expose private keys
Test Thoroughly: Test with small amounts first
Security Considerations
Inspect Before Signing
Simulate Before Sending
Error Handling
Same error codes as Lightning API apply. See Error Handling.
Next Steps
View WebSocket API for real-time data
Check Examples for complete integration code
Learn about Error Handling
Last updated

