Crate multisig_lite

Crate multisig_lite 

Source
Expand description

A native SOL multisig on-chain program.

§Examples

Here is how to create a new multisig account on-chain.

Please refer to the multisig_lite module level documentation for the other instructions’ example.

use std::rc::Rc;

use solana_sdk::commitment_config::CommitmentConfig;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::read_keypair_file;
use solana_sdk::signer::Signer;
use solana_sdk::system_program;

use anchor_client::{Client, Cluster};

let url = Cluster::Devnet;
let funder = Rc::new(read_keypair_file(
    shellexpand::tilde("~/.config/solana/id.json").as_ref(),
)?);
let opts = CommitmentConfig::processed();
let pid = multisig_lite::id();
let program = Client::new_with_options(url, funder.clone(), opts).program(pid);

// Gets the PDAs.
let (state_pda, state_bump) =
    Pubkey::find_program_address(&[b"state", funder.pubkey().as_ref()], &pid);
let (fund_pda, fund_bump) = Pubkey::find_program_address(&[b"fund", state_pda.as_ref()], &pid);

// Creates a multisig account.
let sig = program
    .request()
    .accounts(multisig_lite::accounts::Create {
        funder: funder.pubkey(),
        state: state_pda,
        fund: fund_pda,
        system_program: system_program::id(),
    })
    .args(multisig_lite::instruction::Create {
        m: 2, // m as in m/n.
        signers: vec![funder.pubkey(), Pubkey::new_unique(), Pubkey::new_unique()],
        q: 10, // transfer queue limit.
        _state_bump: state_bump,
        fund_bump,
    })
    .signer(funder.as_ref())
    .send()?;

println!("{sig}");

Modules§

accounts
An Anchor generated module, providing a set of structs mirroring the structs deriving Accounts, where each field is a Pubkey. This is useful for specifying accounts for a client.
instruction
An Anchor generated module containing the program’s set of instructions, where each method handler in the #[program] mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when speciying instructions on a client.
multisig_lite
Module representing the program instruction handlers.
program
Module representing the program.

Structs§

Approve
Accounts for the multisig_lite::approve instruction handler.
Close
Accounts for the multisig_lite::close instruction handler.
Create
Accounts for the multisig_lite::create instruction handler.
CreateTransfer
Accounts for the multisig_lite::create_transfer instruction handler.
Fund
Accounts for the multisig_lite::fund instruction handler.
State
A multisig State PDA account data.
Transfer
A multisig Transfer account data.

Enums§

Error
A multisig program specific error code.

Statics§

ID
The static program ID

Functions§

check_id
Confirms that a given pubkey is equivalent to the program ID
entry
The Anchor codegen exposes a programming model where a user defines a set of methods inside of a #[program] module in a way similar to writing RPC request handlers. The macro then generates a bunch of code wrapping these user defined methods into something that can be executed on Solana.
entrypoint
Safety
id
Returns the program ID