1

I have a very simple program which stores GIFs in a solana contract. Before I can get the gifs, however, I believe I need to call the "initialize" function in my front-end. I have created the logic/button for this, but it is not recognizing "initialize" as a function and is, instead, looking for "startStuffOff", despite me never using this phrase. However, the tests run correctly and I used anchor idl init to make sure my idl was up-to-date. I am wondering why the front end can't find my function? I have attached a photo of the relevant code to show thatmy function is called "initialize", my tests are running, and I am using the same logic to try to call the same function on the front-end. The error that I get in the console is TypeError: program.methods.initialize is not a function

My relevant dependencies in my package.json are:

 "@project-serum/anchor": "^0.25.0",
    "@solana/web3.js": "^1.66.2"

enter image description here

1
  • Kindly share GitHub repo link so I dig into it and find the issue. Commented Oct 24, 2022 at 4:58

1 Answer 1

1

I don't see any function called initialize in the image you've attached. There's a difference between having an Initialize struct and an initialize function. I bet you have a function start_stuff_off that calls the Initialize struct in the lib.rs file. Replace it with:

pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
//rest of the code here
 ...
}

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.