8 releases

0.0.8 Feb 13, 2023
0.0.7 Feb 11, 2023

#18 in #multisig

Download history 92/week @ 2024-02-15 3/week @ 2024-02-22 1/week @ 2024-02-29 3/week @ 2024-03-07 2/week @ 2024-03-14 34/week @ 2024-03-28 17/week @ 2024-04-04

51 downloads per month

MIT/Apache

49KB
360 lines

multisig-lite

CI License Cargo Documentation

A native SOL multisig on-chain program for Solana Blockchain.

Currently, there are five instructions to provide the queued multisig transfer operation:

  1. create
  2. fund
  3. create_transfer
  4. approve
  5. close

Examples

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

Please refer to the multisig_lite::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};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    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()?;

    Ok(())
}

Test

You can run solana-program-test based functional tests with the standard cargo test command:

$ cargo test

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~19–30MB
~488K SLoC