Reputation: 1
We're utilizing React version 16 and Node.js version 16. While creating an anchor provider to retrieve the program, we're encountering an error: "Failed to send transaction: Transaction precompile verification failure InvalidAccountIndex." How can we resolve this issue?
import { useAnchorWallet, useConnection, useWallet } from "@solana/wallet-adapter-react";
import nacl from "tweetnacl";
import * as anchor from "@project-serum/anchor"
import { Keypair, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
const {connection} = useConnection();
const { publicKey } = useWallet();
const wallet = useAnchorWallet();
var provider = new anchor.AnchorProvider(connection, wallet as any, {});
anchor.setProvider(provider);
const program = new anchor.Program(IDL, PROGRAM_ID);
try {
const main_tx = await wctx.fn_buy_token_by_token_with_permission(
pool_index,
provider.publicKey,
new anchor.BN(max_amount),
new anchor.BN(min_amount),
signature1,
buy_currency,
new anchor.BN(token_to_spend),
buy_token_account,
);
const tx = await provider.sendAndConfirm(main_tx);
} catch (err) {
console.log(err, "ERROR");
}
Package.json File
.......
"@project-serum/anchor": "^0.26.0",
"@solana/spl-token-group": "^0.0.2",
"@solana/spl-token-metadata": "^0.1.2",
"@solana/wallet-adapter-react": "^0.15.8",
"@solana/wallet-adapter-react-ui": "^0.9.35",
"@solana/wallet-adapter-wallets": "^0.16.9",
"@solana/web3.js": "^1.50.1",
.......
import { useAnchorWallet, useConnection, useWallet } from "@solana/wallet-adapter-react";
import nacl from "tweetnacl";
import * as anchor from "@project-serum/anchor"
import { Keypair, PublicKey, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
const {connection} = useConnection();
const { publicKey } = useWallet();
const wallet = useAnchorWallet();
var provider = new anchor.AnchorProvider(connection, wallet as any, {});
anchor.setProvider(provider);
const program = new anchor.Program(IDL, PROGRAM_ID);
try {
const main_tx = await wctx.fn_buy_token_by_token_with_permission(
pool_index,
provider.publicKey,
new anchor.BN(max_amount),
new anchor.BN(min_amount),
signature1,
buy_currency,
new anchor.BN(token_to_spend),
buy_token_account,
);
const tx = await provider.sendAndConfirm(main_tx);
} catch (err) {
console.log(err, "ERROR");
}
Upvotes: 0
Views: 364