Transaction simulation failed error

Hi. I’m testing token-vesting here GitHub - Bonfida/token-vesting: A Vesting Contract for the Solana Blockchain on devnet. I’m getting error

Transaction simulation failed: Attempt to load a program that does not exist

I think I put right Info about the desintation, token, source token, spc, decimals. what can be occurred from that error?

The error message is quite explicit, your passing the wrong program id. The devnet program id is different from the mainnet program id token-vesting/js at master · Bonfida/token-vesting · GitHub

Hi. Thanks for the reply. I just checked the program id. I looked through all the files in js. but I’m not sure about where exactly should I put it the program Id. If you don’t can you guide me?

HI. I really appreciate your help. since I change the code, I got the other error which is custom program error. I saw some people having this problem on issue on github. what’s the problem? :frowning:

Can you please share your code? And also copy/paste the logs instead of screenshot?

onst WALLET_PATH = '/Users/chunghyunpark/.config/solana/id_owner.json';
const wallet = Keypair.fromSecretKey(
  new Uint8Array(JSON.parse(fs.readFileSync(WALLET_PATH).toString())),
);

/** There are better way to generate an array of dates but be careful as it's irreversible */
const DATES = [
  new Date(2022, 12),
  new Date(2023, 1),
  new Date(2023, 2),
  new Date(2023, 3),
  new Date(2023, 4),
  new Date(2023, 5),
  new Date(2023, 6),
  new Date(2023, 7),
  new Date(2023, 8),
  new Date(2023, 9),
  new Date(2023, 10),
  new Date(2023, 11),
  new Date(2024, 12),
  new Date(2024, 2),
  new Date(2024, 3),
  new Date(2024, 4),
  new Date(2024, 5),
  new Date(2024, 6),
  new Date(2024, 7),
  new Date(2024, 8),
  new Date(2024, 9),
  new Date(2024, 10),
  new Date(2024, 11),
  new Date(2024, 12),
];

/** Info about the desintation */
const DESTINATION_OWNER = new PublicKey('DXtZSax77sRkF7BzCpUGQesBCG6nQ9r1iEZ53tgT8bJp');
const DESTINATION_TOKEN_ACCOUNT = new PublicKey('6Q3dbaKpdFqwfczbXeQxBmgZKVqN7TmzK2CPb3osgUue');

/** Token info */
const MINT = new PublicKey('Cbjxnqp9cndpse9bJ6acDjB4TuiJYCUgcZWgrVXhiitM');
const DECIMALS = 9;

/** Info about the source */
const SOURCE_TOKEN_ACCOUNT = new PublicKey('7HUFjp5n5n4ZYmMPequqWUPwxGM21qdYuyNTSH74YyQT');

/** Amount to give per schedule */
const AMOUNT_PER_SCHEDULE = 1;

/** Your RPC connection */
const connection = new Connection('https://api.devnet.solana.com');

/** Do some checks before sending the tokens */
const checks = async () => {
  const tokenInfo = await connection.getParsedAccountInfo(
    DESTINATION_TOKEN_ACCOUNT,
  );

  // @ts-ignore
  const parsed = tokenInfo.value.data.parsed;
  if (parsed.info.mint !== MINT.toBase58()) {
    throw new Error('Invalid mint');
  }
  if (parsed.info.owner !== DESTINATION_OWNER.toBase58()) {
    throw new Error('Invalid owner');
  }
  if (parsed.info.tokenAmount.decimals !== DECIMALS) {
    throw new Error('Invalid decimals');
  }
};
Seed: 0604223443467676492642114412489617589014970147561336459914778376
Vesting contract account pubkey:  HWfHFegh3Bp2a4fXekFZQDNReP5rcYU8V2nQAFa9ucoX
contract ID:  4FCVeUA8WaRKEsma2QZpeSs6xPy4kMhG3QTXfNfoSri8
Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
    Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ invoke [1]
    Program log: Entrypoint
    Program log: Beginning processing
    Program log: Error: Invalid instruction!
    Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ consumed 1540 of 200000 compute units
    Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ failed: custom program error: 0x0
/Users/chunghyunpark/Desktop/Vesting/token-vesting/js/node_modules/@solana/web3.js/lib/index.cjs.js:6591
      throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
            ^

SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x0
    at Connection.sendEncodedTransaction (/Users/chunghyunpark/Desktop/Vesting/token-vesting/js/node_modules/@solana/web3.js/lib/index.cjs.js:6591:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Connection.sendRawTransaction (/Users/chunghyunpark/Desktop/Vesting/token-vesting/js/node_modules/@solana/web3.js/lib/index.cjs.js:6550:20)
    at async Connection.sendTransaction (/Users/chunghyunpark/Desktop/Vesting/token-vesting/js/node_modules/@solana/web3.js/lib/index.cjs.js:6540:12)
    at async Object.signTransactionInstructions (/Users/chunghyunpark/Desktop/Vesting/token-vesting/js/dist/utils.js:135:12)
    at async lock (/Users/chunghyunpark/Desktop/Vesting/token-vesting/js/dist/dev.js:89:16) {
  logs: [
    'Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ invoke [1]',
    'Program log: Entrypoint',
    'Program log: Beginning processing',
    'Program log: Error: Invalid instruction!',
    'Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ consumed 1540 of 200000 compute units',
    'Program Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ failed: custom program error: 0x0'
  ]
}
error Command failed with exit code 1.
export const TOKEN_VESTING_PROGRAM_ID = new PublicKey(
  'Hj9R6bEfrULLNrApMsKCEaHR9QJ2JgRtM381xgYcjFmQ',
);

if you need other things let me know! I will stay!

The code you copy pasted does not lock anything, it just performs checks. Also what’s the pubkey you are using?

3qWQjGDuRqxr4nyBZjyTcCLyaJwRDWQQvpNFZuHSEb8k
DXtZSax77sRkF7BzCpUGQesBCG6nQ9r1iEZ53tgT8bJp
EZKKw5a22SsHBAJJTiCjjjqecvECpU4WUyRqEsnJotAV

I made these pubkey following

solana-keygen new --outfile ~/.config/solana/id_owner.json --force
solana-keygen new --outfile ~/.config/solana/id_dest.json --force
solana-keygen new --outfile ~/.config/solana/id_new_dest.json --force

Can you post the part of the code you are using to lock the tokens? And also specify which pubkey is which?

Sorry for the late reply. I’m not sure you want this:

const lock = async () => {
  await checks();
  const schedules: Schedule[] = [];
  for (let date of DATES) {
    schedules.push(
      new Schedule(
        /** Has to be in seconds */
        new Numberu64(date.getTime() / 1_000),
        /** Don't forget to add decimals */
        new Numberu64(AMOUNT_PER_SCHEDULE * Math.pow(10, DECIMALS)),
      ),
    );
  }
  const seed = generateRandomSeed();

  console.log(`Seed: ${seed}`);

  const instruction = await create(
    connection,
    TOKEN_VESTING_PROGRAM_ID,
    Buffer.from(seed),
    wallet.publicKey,
    wallet.publicKey,
    SOURCE_TOKEN_ACCOUNT,
    DESTINATION_TOKEN_ACCOUNT,
    MINT,
    schedules,
  );

  const tx = await signTransactionInstructions(
    connection,
    [wallet],
    wallet.publicKey,
    instruction,
  );

  console.log(`Transaction: ${tx}`);
};

lock();

and I think I’m using this as pubKey:

3qWQjGDuRqxr4nyBZjyTcCLyaJwRDWQQvpNFZuHSEb8k

This pubkey has no SOL and no token Explorer | Solana

I put 2 sol and tried again but it doens’t work. :frowning: do I have to mint token to that pubkey?
Since I’m using this spl-token create-token --url https://api.devnet.solana.com --fee-payer ~/.config/solana/id_owner.json. Do I have to vim and add Pubkey in it?

The wallet used needs to be holding the tokens you want to lock

Okay. I think I’m not right on the track right now. I apologized keep bothering you, so what I have to do is my account in id_owner.json should hold the token that I mint. am I right?

The wallet (i.e Keypair object) you use to sign and send the tx need to be holding the tokens you want to lock. You cannot lock tokens you do not own.

I redeployed the program on devnet to make sure it’s the same as the one on mainnet DLxB9dSQtA4WJ49hWFhxqiQkD9v6m67Yfk9voxpxrBs4

I got it. I will try first !

1 Like

Hi. It works and I have an another question. I test it 3 times and when I check transections in solscan. token was sent by ramdomly. How can I set destination specifically?

Seed: 2024051340328867891205690701560787426505076188129329686952177896
Vesting contract account pubkey:  J8RTqe9oyeQPDvxwDseqYH9dhrtfMvutL99kZYM5zbaD
contract ID:  4Nv1ZsSttvVsAxRtyP5YSQxN5rYaDC4bV8kMqSBPSUVL
Transaction: 2eG14ckjiZuTYag7qgZxySLaHd2dsZWCSqejsUkaZ3T1wCz1W23jFccE1w1LJH3WqoYjs9EkKRQeuE8FZKCH2Z9v
✨  Done in 7.74s.
➜  js git:(master) ✗ yarn build
yarn run v1.22.10
$ tsc
✨  Done in 0.77s.
➜  js git:(master) ✗ 2eG14ckjiZuTYag7qgZxySLaHd2dsZWCSqejsUkaZ3T1wCz1W23jFccE1w1LJH3WqoYjs9EkKRQeuE8FZKCH2Z9v
zsh: command not found: 2eG14ckjiZuTYag7qgZxySLaHd2dsZWCSqejsUkaZ3T1wCz1W23jFccE1w1LJH3WqoYjs9EkKRQeuE8FZKCH2Z9v
➜  js git:(master) ✗ yarn dev
yarn run v1.22.10
$ tsc && node dist/dev.js
Seed: 9454963339849575630755191518458454295599354115797797986947056659
Vesting contract account pubkey:  DjRhFZjAZcn4ouGK5ARZKNgqAA1SmTEgpYEzS1rVMtzy
contract ID:  4rJQskx81Lx2UkSipRHREwvs5ZNMcDfef6Bh9LcXkwYg
Transaction: 4RimpuD5vfeQqNuv7GNr3q6WqqMtVjwqwX51icVxMPHaLMTmewtLCEqWcccepw13NZWnYbLZjHUfN8thJLVDyamh
✨  Done in 7.52s.
➜  js git:(master) ✗ yarn build
yarn run v1.22.10
$ tsc
✨  Done in 0.82s.
➜  js git:(master) ✗ yarn dev
yarn run v1.22.10
$ tsc && node dist/dev.js
Seed: 5909376074788684768820085388356109609684076434081733949400338587
Vesting contract account pubkey:  8aom5cV2we88KGFNbtDrrJ18PdzocEsPvefwkRjmwYoj
contract ID:  4amBmb62b9DL3t5jA5Wc57TWLzbe9tf3pfgdLJqYHckc
Transaction: 5wSF1ozE9LJTdMsxRz237hY4wtMbdpJKcaPm1GH53r5obEHisznWJJQBzDoTBe7jppeF69HpLuhnShnBEoSqNtzH
✨  Done in 7.55s.

here is where I want to send it.

const DESTINATION_OWNER = new PublicKey('2125sHyMfkifEKxct7xsvsoWBGLi7cro6RqpfmnPpHTB');

const DESTINATION_TOKEN_ACCOUNT = new PublicKey('F3fy5HTczEd8M5nLR3dhD5rCpbthGARi1L28qHp9jz28');

Tokens are sent to the vesting account which is an escrow wallet holding the tokens. This account is generated randomly. Tokens are only released to the destination token account you specify when they unlock.

The logic of the program is described in this diagram token-vesting/structure.png at master · Bonfida/token-vesting · GitHub