TypeScript SDK
Transaction Building
Sponsored Transactions

Sponsored Transactions

The transaction builder can support sponsored transactions by using the onlyTransactionKind flag when building the transaction.

const tx = new Transaction();
 
// ... add some transactions...
 
const kindBytes = await tx.build({ provider, onlyTransactionKind: true });
 
// construct a sponsored transaction from the kind bytes
const sponsoredtx = Transaction.fromKind(kindBytes);
 
// you can now set the sponsored transaction data that is required
sponsoredtx.setSender(sender);
sponsoredtx.setGasOwner(sponsor);
sponsoredtx.setGasPayment(sponsorCoins);