1

I want to access the data of a transaction , for example I want to be able to access the metadata of this token. How do I go about it enter image description here Right now this is what I'm using to get the transaction message

let tx=await connection.getTransaction("5swq5xq6fDMvdo8N3dHWLiTMbR73Qps18BuVrDbuNoWS6PQjtPHcr2Tzv1sBE7hzcnMwNk6aH3MzZG6HWXqv6TdY")
console.log("here", tx?.transaction?.message)

Which gets me this enter image description here

1 Answer 1

1

The transaction message does not give you the account contents, only the account pubkeys and instruction data involved. The metadata information is stored in one of those accounts, and you'll have to fetch it separately.

In your case, if you want to get the metadata for a token account, you'll need to find the metadata account, by looking through the instructions, pulling out the index, getting the pubkey from accountKeys, calling connection.getAccountInfo on the correct pubkey, and finally deserializing that account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.