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:

  1. Request a payment transaction from Yuzu402

  2. Receive base64-encoded unsigned transaction

  3. Sign the transaction with your wallet

  4. 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:

Parameter
Type
Required
Description

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:

Parameter
Type
Required
Description

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

  1. Verify Transaction Contents: Inspect the transaction before signing

  2. Use Trusted RPC: Use your own RPC or a trusted provider

  3. Handle Expiration: Build and send transactions quickly

  4. Confirm Transactions: Always wait for confirmation

  5. Store Private Keys Securely: Never expose private keys

  6. 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

Last updated