Skip to main content
added 12 characters in body
Source Link
zOthix
  • 101
  • 1

I'm working with a Solana program and I have the following code:

#[derive(Accounts)]
pub struct SomeStruct<'info> {
    #[account()]
    pub state: Account<'info, State>,
    ....
}

I'm initializing this statestate variable of SomeStruct in the initializer of the contract, which can't be initialized twice using the initializer functionreinitialized.

pub fn lock_tokens(ctx: Context<SomeStruct>, amount: u64) -> Result<()> {
   ...
}

This functionlock_tokens now needs the SomeStructSomeStruct to perform its internal logic. Is it possible for someone to initialize their own statestate account with dummy data and pass it into the contract in SomeStruct? If so, how can one do that?

I'm working with a Solana program and I have the following code:

#[derive(Accounts)]
pub struct SomeStruct<'info> {
    #[account()]
    pub state: Account<'info, State>,
    ....
}

I'm initializing this state in the initializer of the contract, which can't be initialized twice using the initializer function.

pub fn lock_tokens(ctx: Context<SomeStruct>, amount: u64) -> Result<()> {
   ...
}

This function now needs the SomeStruct to perform its internal logic. Is it possible for someone to initialize their own state account with dummy data and pass it into the contract? If so, how can one do that?

I'm working with a Solana program and I have the following code:

#[derive(Accounts)]
pub struct SomeStruct<'info> {
    #[account()]
    pub state: Account<'info, State>,
    ....
}

I'm initializing this state variable of SomeStruct in the initializer of the contract, which can't be reinitialized.

pub fn lock_tokens(ctx: Context<SomeStruct>, amount: u64) -> Result<()> {
   ...
}

lock_tokens now needs the SomeStruct to perform its internal logic. Is it possible for someone to initialize their own state account with dummy data and pass it into the contract in SomeStruct? If so, how can one do that?

Source Link
zOthix
  • 101
  • 1

Can users pass Dummy State Accounts in Solana Program?

I'm working with a Solana program and I have the following code:

#[derive(Accounts)]
pub struct SomeStruct<'info> {
    #[account()]
    pub state: Account<'info, State>,
    ....
}

I'm initializing this state in the initializer of the contract, which can't be initialized twice using the initializer function.

pub fn lock_tokens(ctx: Context<SomeStruct>, amount: u64) -> Result<()> {
   ...
}

This function now needs the SomeStruct to perform its internal logic. Is it possible for someone to initialize their own state account with dummy data and pass it into the contract? If so, how can one do that?