I don’t understand how to call any of the instructions at a given program address: “voTpe3tHQ7AjQHMapgSue2HJFAh2cGsdokqN3XqmVSj”
I want to call the NewEscrow instruction, but I get this error:
‘Program log: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported.’
const solanaWeb3 = require('@solana/web3.js');
const splToken = require('@solana/spl-token');
const bip39 = require('@scure/bip39');
const bs58 = require('bs58');
const { wordlist } = require('@scure/bip39/wordlists/english');
const connection = new solanaWeb3.Connection(solanaWeb3.clusterApiUrl('mainnet-beta'), 'confirmed');
const mnemonic = bip39.generateMnemonic(wordlist)
const seed = await bip39.mnemonicToSeed(mnemonic)
const hdkey = slip10.HDKey.fromMasterSeed(seed)
const derivedKeyFirstAcc = hdkey.derive("m/44'/501'/1'/0'", mnemonic);
const derivedKey = hdkey.derive("m/44'/501'/2'/0'", mnemonic);
const keyPairFirstAcc = solanaWeb3.Keypair.fromSeed(derivedKeyFirstAcc['privateKey']);
const keyPair = solanaWeb3.Keypair.fromSeed(derivedKey['privateKey']);
const toPublicKeyString = keyPair.publicKey.toString();
const fromSecretKey = keyPairFirstAcc.secretKey;
const from = solanaWeb3.Keypair.fromSecretKey(fromSecretKey);
const to = new solanaWeb3.PublicKey(toPublicKeyString);
const programId = new solanaWeb3.PublicKey('voTpe3tHQ7AjQHMapgSue2HJFAh2cGsdokqN3XqmVSj')
jupVote(from,to, keyPair).catch(err => {console.error(err);});
async function jupVote(from,to, keyp) {
let keys = [
{
pubkey:to,
isSigner:true,
isWritable:true
}
]
const instructionData = Buffer.alloc(8);
instructionData.writeUInt32LE('NewEscrow', 0);
const createInstruction = new solanaWeb3.TransactionInstruction({
keys:keys,
data: instructionData,
programId: programId
})
const transaction = new solanaWeb3.Transaction().add(createInstruction);
const signature = await solanaWeb3.sendAndConfirmTransaction(
connection,
transaction,
[keyp],
{
commitment: 'confirmed',
}
);
console.log('Transaction signature', signature);
}
New contributor
Nikolay37 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.