I cannot send the transaction here. Tried using wallet-adapter methods as well as solana/web3js methods, tried separating sendTransaction and confirmTransaction. Similar "cannot read .toString() of undefined" error for all the methods but at different places in the module.
Code
const { connection } = useConnection();
const wallet = useWallet();
const burnAndSendSol = async () => {
const associatedAddress = await getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
mintPublickey,
publicKey
);
const burnInstruction = createBurnCheckedInstruction(
associatedAddress,
mintPublickey,
publicKey,
1,
TOKEN_PROGRAM_ID
);
const burnAndTransferTransaction = new Transaction().add(
burnInstruction,
SystemProgram.transfer({
fromPubkey: publicKey,
toPubkey: vaultPubKey,
lamports: 0.5 * LAMPORTS_PER_SOL,
})
);
try {
const txn = await sendAndConfirmTransaction(
connection,
burnAndTransferTransaction,
[wallet]
);
} catch (error) {
console.log(error);
}
}
Error Stacktrace
TypeError: Cannot read properties of undefined (reading 'toString')
at eval (index.browser.esm.js?156f:2629:1)
at Array.forEach (<anonymous>)
at Transaction.compileMessage (index.browser.esm.js?156f:2628:1)
at Transaction._compile (index.browser.esm.js?156f:2749:1)
at Transaction.sign (index.browser.esm.js?156f:2854:1)
at Connection.sendTransaction (index.browser.esm.js?156f:7386:1)
at async sendAndConfirmTransaction (index.browser.esm.js?156f:3130:1)
toString()
is failing. Either turn on sourcemaps in your project so that we get actual line numbers, or edit the implementation ofTransaction.compileMessage()
in your source to debug whichtoString()
call is being called onundefined
.