0

I have a query like I have deployed a token on mainnet and has declared that token on the anchor contracts. Now I want to know the best practices such that I can test in locally using anchor test . Previously I was using this in local testnet to extract mainnet information locally

const connection_mainnet = new Connection(clusterApiUrl('mainnet-beta'),'confirmed');
tokenMainPubkey = new anchor.web3.PublicKey("tokenPubkey")

let accountInfo = await connection_mainnet.getParsedAccountInfo(tokenMainPubkey);

const tokenAccountInfo = await connection_mainnet.getAccountInfo(tokenMainPubkey);
console.log("token account info",tokenAccountInfo)

And this want returning me the mainnet information

But when I am using this on my initialize function so it and run test case, it returns this error

Error

Error: AnchorError caused by account: tai_mint. Error Code: AccountNotInitialized. Error Number: 3012. Error Message: The program expected this account to be already initialized.

3
  • 1
    The error means that the token account isn't initialized and I'd assume the same goes for your token mint. Try switching to devnet in the Connection object and Anchor.toml config. Is your program also deployed?
    – Jimii
    Commented Jun 28 at 8:18
  • Yes it says that ,token account is not initialized but I want to know the best practices since the token is already deployed what can I do further to perform test cases in local environment is it possible or not?
    – hammad ali
    Commented Jun 28 at 18:24
  • This answer seems really helpful: solana.stackexchange.com/a/626 Commented Oct 27 at 17:53

0

Your Answer

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