Parameters

In addition to the above set of accounts, we need some extra information from the user in order to properly configure the vesting contract. We only have access to a user-provided slice of bytes, called the instruction data. This slice of bytes can be cast into a Params wrapper object. The approach will be very similar to the way we handled the VestingContract object in the previous section.

Let's take a direct look at the Params struct:

#[derive(WrappedPod)]
pub struct Params<'a> {
    // Needs to be a `u64` for the schedules slice to be well-aligned in memory
    signer_nonce: &'a u64,
    schedule: &'a [VestingSchedule]
}

In order to handle Params being a wrapped Pod in our Rust instruction bindings, we need to activate the instruction_params_wrapped feature. In the program Cargo.toml, edit the bonfida-utils dependency to:

bonfida-utils = {version = 0.2, features = ["instruction_params_wrapped"]}

Then in instruction.rs, update the create binding to:

#[allow(missing_docs)]
pub fn create(accounts: create::Accounts<Pubkey>, params: create::Params) -> Instruction {
    accounts.get_instruction_wrapped_pod(crate::ID, ProgramInstruction::Create as u8, params)
}

We will discuss why the signer_nonce parameter is required in a later section. In combination with the accounts defined above, we have all the information we need to begin writing the instruction logic!