Sponsor Transactions using wallets #484
Unanswered
alaasouabni
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Discord user ID
alaa7952
Describe your question in detail.
Is there a way to let the user sign a sponsored transaction (the user will sponsor it) using wallets? i tried it using Petra, Martian, Nightly and Pontem and none of them seem to work, i'm getting INVALID_SIGNATURE error.
What error, if any, are you getting?
INVALID_SIGNATURE error is generated after i try to submit the transaction after signing it by both the fee payer and the sender account.
What have you tried or looked at? Or how can we reproduce the error?
import {
AptosConfig,
Aptos,
Network,
Account,
Ed25519PrivateKey,
} from "@aptos-labs/ts-sdk";
import { PetraWallet } from "petra-plugin-wallet-adapter";
const aptosConfig = new AptosConfig({ network: Network.TESTNET });
const aptos_sdk = new Aptos(aptosConfig);
const pvt_key_acc1 = new Ed25519PrivateKey("0x...");
const acc1 = Account.fromPrivateKey({
privateKey: pvt_key_acc1,
});
const txn = await aptos_sdk.transaction.build.simple({
sender: acc1.accountAddress,
withFeePayer: true,
data: {
function:
${movePublisher}::lootbox::open_lootbox
,typeArguments: [],
functionArguments: [walletAddress],
},
});
const acc1_sign = aptos_sdk.transaction.sign({
signer: acc1,
transaction: txn,
});
// signing using petra wallet as a fee payer
const wal = new PetraWallet();
await wal.connect();
const signfeepayer = await wal.signTransaction(txn, true); // true for sign as fee payer
const commited_txn = await aptos_sdk.transaction.submit.simple({
transaction: txn,
senderAuthenticator: acc1_sign,
//@ts-ignore
feePayerAuthenticator: signfeepayer,
});
Which operating system are you using?
Windows
Which SDK or tool are you using? (if any)
TypeScript SDK
Describe your environment or tooling in detail
No response
Beta Was this translation helpful? Give feedback.
All reactions