Quantcast
Channel: Multiple instruction constraints anchor - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 2

Multiple instruction constraints anchor

$
0
0

If I want to use instruction data in my account constraints, I can do it like so:

#[derive(Accounts)]#[instruction(my_param: u32)]pub struct MyAccounts<'info> {    #[account(        seeds = [my_param.to_le_bytes().as_ref()],        bump    )]    pub my_account: Account<'info, MyAccount>,}

Let's say I want to use multiple params. Intuitively, I tried the below:

#[derive(Accounts)]#[instruction(my_param: u32)]#[instruction(my_second_param: u32)]pub struct MyAccounts<'info> {    #[account(        seeds = [my_param.to_le_bytes().as_ref(), my_second_param.to_le_bytes().as_ref()],        bump    )]    pub my_account: Account<'info, MyAccount>,}

This gives me the error cannot find value "my_second_param" in this scope. Is there a way to achieve this out of the box (which isn't merging my two params into a struct)? Or does anchor only allow one instruction constraint?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>