1

I am trying to use simulateTransaction passing account to receive the post balance of those accounts but I am only getting the post balance of the main account not token accounts.

I have tried with different options in the config and nothing, I can only get the post balance of the main account (the one holding SOL).

const accounts = ['main address', 'token account 1', 'token account 2', 'etc']

const config = {
    sigVerify: true,
    accounts: {
       encoding: 'base64',
       addresses: accounts,
    },
    commitment: 'finalized',
    replaceRecentBlockhash: false
}
await connection.simulateTransaction(tx, config)

In the post balance I should receive - 1 of a token account that is holding an NFT because I am delisting one NFT from tensor, but I am only getting SOL post balance.

1 Answer 1

1

To get the post token balances, you'll need to parse out the data of each account. If you request jsonParsed encoding, you'll get back the token account balance already parsed, ie:

const response = await connection.simulateTransaction(tx, config);
const newAmount = response.value.accounts[0].data.parsed.tokenAmount.amount;

The parsed response will look like the entries in https://docs.solana.com/api/http#gettokenaccountsbyowner

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.