# Validation

**EVM**

```solidity
contract Dex {
  bool private _paused;
  
  function setPaused(bool paused) external {
    if (msg.sender != owner) {
      revert NotOwner();
    }
    
    _paused = paused;
  }
}
```

**Solana**

1. Using **constraint**

```rust
#[account]
pub struct Config {
  pub authority: Pubkey,
  pub paused: bool,
}

#[derive(Accounts)]
pub struct SetPaused<'info> {
  pub signer: Signer<'info>,
  
  #[account(mut, constraint = config.authority == signer.key() @ ErrorCode::Unauthorized)]
  pub config: Account<'info, Config>
}


pub fn set_paused(Context<SetPaused, bool paused) -> Result<()> {
  ctx.accounts.config.paused = paused;
}
```

2. Using **require!**

```rust
#[account]
pub struct Config {
  pub authority: Pubkey,
  pub paused: bool,
}

#[derive(Accounts)]
pub struct SetPaused<'info> {
  pub signer: Signer<'info>,
  
  #[account(mut, constraint = config.authority == signer.key() @ ErrorCode::Unauthorized)]
  pub config: Account<'info, Config>
}


pub fn set_paused(Context<SetPaused, bool paused) -> Result<()> {
  require!(ctx.accounts.config.authority == ctx.accounts.signer.key(), ErrorCode::Unauthorized);
  ctx.accounts.config.paused = paused;
}
```

3. Using **has\_one**

Notice how I've changed the caller's field name from `signer` to `authority. has_one` is looking for an account called `authority` that matches the account `config`'s `authority`.

```rust
#[account]
pub struct Config {
  pub authority: Pubkey,
  pub paused: bool,
}

#[derive(Accounts)]
pub struct SetPaused<'info> {
  pub authority: Signer<'info>,
  
  #[account(mut, has_one = authority) @ ErrorCode::Unauthorized)]
  pub config: Account<'info, Config>
}


pub fn set_paused(Context<SetPaused, bool paused) -> Result<()> {
  ctx.accounts.config.paused = paused;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://0xkowloon.gitbook.io/anchor-for-evm-developers/validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
