We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Following the TicTacToe example, I'm trying to pass ctx to a public method flip of Game:
ctx
flip
Game
// instructions/play.rs pub fn play(ctx: Context<Play>, data: FlipArgs) -> Result<()> { ctx.accounts.game.flip(&ctx, data) }
pub fn flip(&mut self, ctx: Context<Play>, data: FlipArgs) -> Result<()> { self.charge_fee(ctx); match data.heads_or_tails { true => self.play_heads(ctx), false => self.play_tails(ctx), } } fn charge_fee(&self, ctx: Context<Play>) -> Result<()> { let player = &ctx.accounts.player; if **player.try_borrow_lamports()? < self.static_amount { return Err(CoinflipError::InsufficientFunds.into()); } let fee = self.calculate_fee(); **player.try_borrow_mut_lamports()? -= fee as u64; Ok(()) }
However, this results in an error:
anchor_lang::context::Context<instructions::play::Play> ctx: Context<Play> anchor_lang::context::Context<instructions::play::Play> ctx: Context<Play> mismatched types expected struct `anchor_lang::context::Context`, found reference
So, how to make ctx work from inside Game in order to access the ctx.accounts.player?
ctx.accounts.player
The text was updated successfully, but these errors were encountered:
pls use discord for support
Sorry, something went wrong.
No branches or pull requests
Following the TicTacToe example, I'm trying to pass
ctx
to a public methodflip
ofGame
:However, this results in an error:
So, how to make
ctx
work from insideGame
in order to access thectx.accounts.player
?The text was updated successfully, but these errors were encountered: