SimpleMultiSig SDK

@soufflejs/simple-multi-sig-sdk

The SimpleMultiSig SDK is a TypeScript SDK for deploying and interacting with a SimpleMultiSig contract.

Example Use

The following is an example of how to use the SDK to connect to a deployed SimpleMultiSig contract and execute a transaction.

import { providers, Wallet } from 'ethers';
import { SimpleMultiSigWallet, SimpleMultiSigWalletOwner } from '@levain-contracts/simple-multi-sig-sdk';

// Connect to Ethereum Node via a node provider
const provider = new providers.AlchemyProvider('goerli', 'YOUR-API-KEY');

// This is the EOA that will be used to execute transactions (call the smart contract wallet's `execute` function)
const executor = new Wallet('EXECUTOR-PRIVATE-KEY').connect(provider);
console.log(executor.address);

// Connect to a deployed wallet
const wallet = new SimpleMultiSigWallet({
  address: '0x8061B2CD8ff2bcB67831653C5cCBA28768291546',
  chainId: provider.network.chainId,
  owners: [
    // Replace with the owners' private keys, or extensions of SimpleMultiSigWalletOwner that handles the signing
    SimpleMultiSigWalletOwner.withPrivateKey('OWNER-1-PRIVATE-KEY'),
    SimpleMultiSigWalletOwner.withPrivateKey('OWNER-2-PRIVATE-KEY'),
  ],
  executor,
});
console.log(`Current wallet's nonce is ${await wallet.getNonce()}`);

// Execute a value transfer transaction
const tx = await wallet.execute({
  destination: '0x21BB2E46d20CbdA97a23444EADFAD1fB691d15D9', // -| a random address
  value: '0x1', // ----------------------------------------------| 1 wei
  data: '0x', // ------------------------------------------------| smart contract call data
  gasLimit: '21000', // -----------------------------------------| gas limit for a value transfer tx
});

const txReceipt = await tx.wait(1);
console.log({ tx, txReceipt });