Code Monkey home page Code Monkey logo

solana-multisig-contract's Introduction

multisig

simple anchor multisig with a UI

developing

anchor build
anchor test

deploying

Make sure to update declare_id! to ~/program-id.json's key first.

solana program deploy -u devnet -k ~/key.json --program-id ~/program-id.json target/deploy/multisig.so

Create a multisig instance

import fs from 'fs';
import anchor, { web3 } from "@project-serum/anchor";

const wallet = new anchor.Wallet(web3.Keypair.fromSecretKey("..."));
const connection = new anchor.web3.Connection("https://api.mainnet-beta.solana.com", "recent");
anchor.setProvider(new anchor.Provider(connection, wallet));
const idl = JSON.parse(fs.readFileSync("./target/idl/multisig.json", "utf-8"));
const programId = new PublicKey("...");
const program = new anchor.Program(idl, programId);

const base = anchor.web3.Keypair.generate();
const [key, bump] = await PublicKey.findProgramAddress([Buffer.from("multisig"), base.publicKey.toBuffer()], programId);
const owners = [wallet.publicKey];

await program.rpc.createMultisig(owners, new BN(1), new BN(0), bump, {
  accounts: {
    signer: wallet.publicKey,
    base: base.publicKey,
    multisig: key,
    systemProgram: web3.SystemProgram.programId,
  },
});

console.log("multisig:", key.toString());

Transfer the upgrade authority to the multisig

solana program set-upgrade-authority PROGRAM-ADDRESS --new-upgrade-authority MULTISIG-ADDRESS

Now you should be able to deploy and use the multisig-ui for you deployed program

license

MIT

solana-multisig-contract's People

Contributors

kiasaki avatar

Stargazers

believe-in-crypto avatar

Watchers

 avatar

Forkers

tiger0105

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.