Error Message
The error message states that x.pubkey.toBase58 is not a function
, meaning that x
doesn't have a pubkey
property, or the pubkey
property on x
doesn't have a toBase58()
method. This suggests that you have a mismatch between the expected type of x
and what's actually being passed.
Without the rest of the code, it's hard to diagnose the exact issue that you're running into. I'd recommend logging the objects and their types, wherever relevant, to get a better understanding of what they actually contain. This can be achieved with something like:
// Log the type and value of x
console.log(typeof x, x);
// Log the type and value of x.pubkey
console.log(typeof x.pubkey, x.pubkey);
You'll want to make sure that all the public keys in your code (mintAddress
, owner
, tokenAccount
, etc.) are instances of Solana's PublicKey
class.
Empty signatures
Array
The signatures
array being empty could imply that the transaction is not being signed properly. You could use the sendAndConfirmTransaction
function from @solana/web3.js
to sign, send, and confirm the transaction all in one go. If not, you'll need to make sure first that the transaction is signed by the appropriate key pair(s). Once you have signed the transaction, then the signatures
array will be populated and you can send the transaction. On Solana, transactions must be signed before they are sent off
Delete Method
The Metaplex Token Metadata documentation has a section on burning NFTs, which can be found here. They give the following example of how to use the SDK to burn an asset on Token Metadata:
import { burnV1 } from '@metaplex-foundation/mpl-token-metadata'
await burnV1(umi, {
mint,
authority: owner,
tokenOwner: owner.publicKey,
tokenStandard: TokenStandard.NonFungible,
}).sendAndConfirm(umi)
This example is helpful as they abstract away the process of constructing the burn instruction manually and setting up the accounts. sendAndConfirm
is also chained to the burnV1
method, which handles the transaction signing and sending in one go. If you're keen on building the transaction yourself, Metaplex has a createBurnNftInstruction
, and the set up is almost identical to your current code except you're using createBurnNftInstruction
instead of burnNft
. The documentation for the createBurnNftInstruction
can be found here
Update [09-13-2023]
Ah! After looking at your code again it looks like you are trying to import burnNft
from @metaplex-foundation/mpl-token-metadata
but Metaplex's burnNft.ts
doesn't have a burnNft
export. Instead, BurnNftStruct
, BurnNftInstructionAccounts
, burnNftInstructionDiscriminator
, and createBurnNftInstruction
are being exported from that file. This might be able to explain as to why you've been experiencing some weird functionality.
If you want to continue on with how you're currently building the transaction, then I'd suggest you import createBurnNftInstruction
instead. Otherwise, Metaplex's new documentation suggests using burnV1
I hope this was helpful!