Sponsored Transactions (Fee Payer)
此内容尚不支持你的语言。
The Kotlin SDK provides support for sponsored transactions also known as fee payer transactions.
The standard flow for sending a sponsored transaction is as follows:
- Determine upon operation by creating a Transaction
- The sender signs the transaction
- The fee payer signs the transaction
- Submit the transaction
Determine Upon Operation
Section titled “Determine Upon Operation”As seen in previous sections, you can build a transaction using buildSimpleTransaction with the lean transaction builder. For sponsored transactions, specify withFeePayer = true.
val txn = aptos.buildSimpleTransaction( sender = alice.accountAddress, withFeePayer = true, ) { function = "0x1::coin::transfer" typeArgs("0x1::aptos_coin::AptosCoin") args(bob.accountAddress, 1_000_000UL) }Sign the Transaction
Section titled “Sign the Transaction”Once built, the sender signs the transaction using sign.
val aliceAuthenticator = aptos.sign(signer = alice, transaction = txn)Sign the Transaction as Fee Payer
Section titled “Sign the Transaction as Fee Payer”The fee payer signs using signAsFeePayer.
val feePayerAuthenticator = aptos.signAsFeePayer(feePayer = sponsor, transaction = txn)Submit the Transaction
Section titled “Submit the Transaction”Submit the transaction with both authenticators.
val pendingTxn = aptos .submitTransaction.simple( transaction = txn, senderAuthenticator = aliceAuthenticator, feePayerAuthenticator = feePayerAuthenticator, ) .expect("Failed to submit transaction")