enter image description here this is my error

enter image description here here is my config

enter image description here

The error occurs on this line: const { tokenAMintAddress, tokenBMintAddress } = await createMintPair(provider). I run it through anchor test ---skip-deploy(anchor test also tried not working, gives the same error). The error says that I don't have enough balance, but in devnet I have 10 sol(Apet9K6okHGofdcKiTFajNTEJWMhADnhHks7isyjsoJd - here is its address) on this wallet. I tried many ways, first I tried through solana-test-validator, I got a lot of solana and nothing worked.Console logs output all the data that could be missing, but everything is fine.Output console provider, also fine, but the problem is that for some reason it gives me this error on the function createMintPair, that is, it does not even enter this function and gives me an error. I saw a theory on the internet that the problem may be that it somehow uses mainnet-beta instead of devnet, maybe it is, but I don't know how to change it (for information anchor.toml I changed to devnet)I don't know what could be the problem, maybe someone has faced this, please tell me.Thanks in adwance enter image description here start of the function createMintPair

enter image description here I tried to do and double-check as you told me, now I made sure that I have exactly the right account.I also changed the lines that relate to the wallet.I double-checked the console logs.It turns out that it should enter exactly the wallet that should be in the function, but still something interferes.

enter image description here

`export async function createMintPair(provider: anchor.Provider) { const connection = provider.connection const wallet = provider.wallet as anchor.Wallet; const tokenA = await Token.createMint( connection, wallet.payer, wallet.publicKey, null, 9, TOKEN_PROGRAM_ID );

const tokenB = await Token.createMint(
const tokenAMintAddress = tokenA.publicKey
const tokenBMintAddress = tokenB.publicKey
const associatedTokenA = await Token.getAssociatedTokenAddress(ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, tokenAMintAddress, wallet.publicKey, true);
const associatedTokenB = await Token.getAssociatedTokenAddress(ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, tokenBMintAddress, wallet.publicKey, true);
const tx1 = new Transaction();
    Token.createAssociatedTokenAccountInstruction(ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, tokenAMintAddress, associatedTokenA, wallet.publicKey, wallet.publicKey),
    Token.createAssociatedTokenAccountInstruction(ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, tokenBMintAddress, associatedTokenB, wallet.publicKey, wallet.publicKey),
let txid = await provider.send(tx1)

const tx2 = new Transaction();
    Token.createMintToInstruction(TOKEN_PROGRAM_ID, tokenAMintAddress, associatedTokenA, wallet.publicKey, [wallet.payer], 100000000000000),
    Token.createMintToInstruction(TOKEN_PROGRAM_ID, tokenBMintAddress, associatedTokenB, wallet.publicKey, [wallet.payer], 200000000000000)
txid = await provider.send(tx2)
console.log("create tokenA: ", tokenA.publicKey.toString(), " tokenB: ", tokenBMintAddress.toString(), "mint txid: ", txid)

return {tokenAMintAddress, tokenBMintAddress}


enter image description here

2 Answers 2


Did you manage to resolve this?

Could be fruitful to check if you have revoked Mint authority of the base token for the pair.

Also, rather than doing a sleep(5000);, waiting for the Commitment of the transaction to be finalized would be more deterministic.


Maybe its using the keypair defined in the anchor toml to sign. So in terminal check

solana address 
solana balance 

and eventually airdrop some sol there. Here are some nice helpers to load keypairs in case you want to use the same that is defined in your anchor toml in your script. https://github.com/solana-developers/helpers?tab=readme-ov-file#getkeypairfromfilefilename

But you probably wanna use this instead:

const provider = anchor.AnchorProvider.env();

  const program = anchor.workspace.TransferHook as Program<TransferHook>;
  const wallet = provider.wallet as anchor.Wallet;
  const connection = provider.connection;

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.