Skip to main content

Questions tagged [constraints]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer

Reducing calls to .load() in constraints

When using constraints with a zero-copy account that uses AccountLoader, you can reduce acc.load() calls like: #[account( mut, constraint = { let acc = some_acc.load()?;...
Whiteseal's user avatar
  • 3,040
1 vote
1 answer

Is there a way I can use find_program_address used to derive a PDA as an anchor constraint

Suppose I have a PDA that is supposed to be initialized by calling a CPI in my program and I want to validate that the account is valid, is there a way I could add a check to make sure that the ...
Jimii's user avatar
  • 1,800
3 votes
1 answer

Check for negative "unsign" interger does not work

I have a function like this: pub fn initialize_pool(ctx: Context<InitializePool>, rate: u64) -> Result<()> { require!(, SwapPoolError::SwapRateError); // {......
agentp's user avatar
  • 235
4 votes
3 answers

Error Code: ConstraintMut. Error Number: 2000. Error Message: A mut constraint was violated.'

failed: custom program error: 0x7d0' pub fn bid(ctx: Context<Bid>, price: u64) -> Result<()> { let auction = &; let bidder = &mut ctx.accounts....
Lobo1897's user avatar
  • 153
5 votes
2 answers

What is an "account revival attack"? Regarding the "#[account(close = <target_account>)]" constraint

Trying to understand how the #[account(close = <target_account>)] constraint works and it says: Marks the account as closed at the end of the instruction’s execution (sets its discriminator to ...
john's user avatar
  • 7,310
8 votes
1 answer

How can I increase an existing account size?

ie. Initialize account with 255 byte space. Pay to double the space through anchor.
user2892730's user avatar
10 votes
4 answers

How to check if a PDA account has/hasn't been initialized?

I am using anchor and I need to check that two different PDAs have not been initialized. Later on in a different function call I need to check if a PDA has been initialized before closing the account. ...
TovarishFin's user avatar