Skip to content

Add sponsored transaction support #7

@whoabuddy

Description

@whoabuddy

Summary

Add support for sponsored (gasless) transactions to enable relay services that cover gas fees for agents.

Changes Needed

  1. Add sponsored?: boolean to PaymentDetails interface in types.ts
  2. Pass sponsored: true flag to makeSTXTokenTransfer() and makeContractCall() in:
    • client.ts: signSTXTransfer, sendSTXTransfer, signSBTCTransfer, sendSBTCTransfer, signUSDCxTransfer, sendUSDCxTransfer
    • interceptor.ts: signPayment

Usage

// Agent builds sponsored tx (no fee)
const signedTx = await client.signPayment(paymentDetails, { sponsored: true });

// Sponsor relay adds fee and broadcasts
const sponsoredTx = await sponsorTransaction({ transaction, sponsorPrivateKey, fee });

Context

Enables x402 sponsor relay pattern where agents submit pre-signed transactions and a relay service covers the gas fees.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions