'error[E0412]: cannot find type `ProgramResult` in this scope
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod myepicproject {
use super::*;
pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> ProgramResult {
Ok(())
}
}
#[derive(Accounts)]
pub struct StartStuffOff {}
I have the source rust code above and the error below.
error[E0412]: cannot find type `ProgramResult` in this scope
--> programs/myepicproject/src/lib.rs:8:58
|
8 | pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> ProgramResult {
| ^^^^^^^^^^^^^ not found in this scope
For more information about this error, try `rustc --explain E0412`.
error: could not compile `myepicproject` due to previous error
Have any suggestion?
Using Anchor
Solution 1:[1]
Try like that:
pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> Result<()> {
Solution 2:[2]
this solves the issue. you have to explicitly import it
use anchor_lang::solana_program::entrypoint::ProgramResult;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | bguiz |
Solution 2 | Yilmaz |