DEV Community

Discussion on: The Complete Guide to Full Stack Solana Development with React, Anchor, Rust, and Phantom

Collapse
 
phoenixdevguru profile image
Legendary Phoenix • Edited

I am also getting this issue. I updated the lib.rs and Anchor.toml files with programID.

Here are the steps I've done.

anchor build
Enter fullscreen mode Exit fullscreen mode

And this returned the programID in the form of public key.

solana address -k target/deploy/example2-keypair.json
>BEPhkwFSf3m5Daz5LZPZhBbeVBkvY3vKnGRiWtNwFn54
Enter fullscreen mode Exit fullscreen mode

Replaced the program id in lib.rs and Anchor.toml

// lib.rs
use anchor_lang::prelude::*;

declare_id!("BEPhkwFSf3m5Daz5LZPZhBbeVBkvY3vKnGRiWtNwFn54");

#[program]
mod example2 {
    use super::*;

... ...
Enter fullscreen mode Exit fullscreen mode
// Anchor.toml
[programs.localnet]
example2 = "BEPhkwFSf3m5Daz5LZPZhBbeVBkvY3vKnGRiWtNwFn54"

[registry]
url = "https://anchor.projectserum.com"

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "mocha -t 1000000 tests/"
Enter fullscreen mode Exit fullscreen mode
anchor deploy
Enter fullscreen mode Exit fullscreen mode

I already checked the programID I am using in the app, and it matches to above one.

// App.js
  async function initialize() {    
    const provider = await getProvider();
    /* create the program interface combining the idl, program ID, and provider */
    const program = new Program(idl, programID, provider);
    console.log(program.programId.toBase58());
Enter fullscreen mode Exit fullscreen mode

But I am still getting this issue when I am trying to call the initialize() function.

Transaction simulation failed: Error processing Instruction 0: custom program error: 0xa7 
    Program BEPhkwFSf3m5Daz5LZPZhBbeVBkvY3vKnGRiWtNwFn54 invoke [1]
    Program 11111111111111111111111111111111 invoke [2]
    Program 11111111111111111111111111111111 success
    Program log: Custom program error: 0xa7
    Program BEPhkwFSf3m5Daz5LZPZhBbeVBkvY3vKnGRiWtNwFn54 consumed 5512 of 200000 compute units
    Program BEPhkwFSf3m5Daz5LZPZhBbeVBkvY3vKnGRiWtNwFn54 failed: custom program error: 0xa7
Enter fullscreen mode Exit fullscreen mode

I am really not sure why this happens and it's bothering me for days. Please help me if you have any idea.

Collapse
 
proto133 profile image
Peter Roto

Did you fund the wallet?