Search code examples
web3jssolanasolana-web3js

Solana Web3.js: Getting `null` for Mint account, althought it should return an `AccountInfo` object


When I run connection.getAccountInfo(watermelonMint.key); I get a null object, although it should return an AccountInfoObject. Any idea why this is the case? When I look for the address associated with this mint on solana explorer, I get normal statistics (https://explorer.solana.com/address/7vLEZP5JHhKVg3HEGSWcFNaxAKg7L633uMT7ePqmn98V?cluster=devnet)

console.log("Watermelon mint is: ");
console.log(watermelonMint);

returns

Mint {conn: Connection, key: PublicKey}
conn: Connection {_commitment: undefined, _confirmTransactionInitialTimeout: undefined, _rpcEndpoint: 'https://api.devnet.solana.com', _rpcWsEndpoint: 'wss://api.devnet.solana.com/', _rpcClient: ClientBrowser, …}
key: PublicKey
_bn: BN {negative: 0, words: Array(11), length: 10, red: null}
[[Prototype]]: Struct
[[Prototype]]: Object

any idea what could cause this?


Update 1:

basically, Token.getMintInfo(); keeps failing

const token = new Token(conn, mint, TOKEN_PROGRAM_ID, {} as any)
  console.log("Getting token: ", token);
  let out: Promise<MintInfo> = token.getMintInfo();
  console.log("Out is: ", out);

Solution

  • Most likely, mint in "Update 1" is incorrect, or that your connection is improperly defined somewhere. Can you double-check that mint is equal to PublicKey("7vLEZP5JHhKVg3HEGSWcFNaxAKg7L633uMT7ePqmn98V")?

    Also, can you make sure to await the response from token.getMintInfo()?