Issue with getOrCreateAssociatedAccountInfo on Quicknode

547 Views Asked by At

I just switched to Quicknode (testnet) as the public Solana node has IP limits. I notice that when I call token.getOrCreateAssociatedAccountInfo I encounter an issue which never happened on the main public node:

{"name":"Error","message":"Failed to find account","stack":"Error: Failed to find account\n    at Token.getAccountInfo (/var/www/node_modules/@solana/spl-token/lib/index.cjs.js:493:13)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Token.getOrCreateAssociatedAccountInfo (/var/www/node_modules/@solana/spl-token/lib/index.cjs.js:338:16)\n    at async SolanaBlockchainAPI.reward (/var/www/src/datasources/solanaBlockchain.js:266:35)

Is there some sort of compatibility issue ?

my code...

const token = new Token(
      connection,
      new web3.PublicKey(token_type.token_address),
      TOKEN_PROGRAM_ID,
      this.appTreasPair
    );



    const recipientTokenAddress = await token.getOrCreateAssociatedAccountInfo(
      new web3.PublicKey(solana_public_address)
    );
1

There are 1 best solutions below

0
On

From the error it looks like there's some trouble locating the account that you're plugging into the getOrCreateAssociatedAccountInfo call.

There's not a lot of info to work with here, but my initial guess is you were working on the public solana devnet, and plugged into a testnet QuickNode URL, which would explain why the account isn't available for you.

Solution here would be to make sure you're on devnet instead of testnet when creating your QuickNode endpoint. Testnet really isn't used very much outside of people testing infrastructure. You're usually either working on production stuff (mainnet) or want to test out different functionalities on the developer testing net (devnet).