Ethereum: How do I pass signers when enabling module for my safe?

Here is an article based on the documentation you provided:

Enable Multiple Signers in a Safe with Ethereum

In this tutorial, we will walk you through the process of enabling multiple signers in a safe using the “@safe-global” library.

Prerequisites

To use multiple signers in your safe, you will first need to create a new instance of the “Safe” class and define the multisig configuration. In this example, we will assume that you are working with a simple multisig setup where one signer can approve two additional signers.

First, install the required library:

npm install @safe-global

Create a new safe instance

Create a new file called “safe.js” and add the following code to define the safe instance:

Import {safe } from '@safe-global';

const mySafe = new Safe({

// Specify multisig configuration here

type: multiSig,

name: 'My Multisig Test',

publicKey: 'yourPublicKey', // Replace with a valid publicKey

privateKey: 'yourPrivateKey', // Replace with a valid privateKey

// Enable multiple signers

enableMultipleSigners: true,

numSigners: {

approvedBySigners: 2, // Number of additional signers authorized to approve transactions

},

});

In this example, we have defined a multisig configuration for our safe, where numSigners is {approvedBySigners: 2}. This means that a signer (the creator of the safe) can approve two additional signers.

Creating Signers

To create multiple signers, you need to create new signing keys and add them to your wallet or a secure storage solution, such as a hardware wallet.

In this example, let’s assume we have a private key named “privateKey” We can generate additional signers using the following code:

const { privateKey, publicKey } = await getPrivateKeyAndPublicKey();

To create a new signer with a specific name and public key, use the following code:

const newSigner = await getNewSigner({

id: 'newsigner',

name: 'John Doe', // Replace with a valid name

publicKey: 'yourPublicKey', // Replace with a valid publicKey

});

Moving signers to the vault

To move signers to the vault, you need to create a new transaction that contains the necessary information (such as the signers’ names and public keys). For this example, let’s assume we have a simple “createTransaction” function:

const createTransaction = async (transactionConfig) => {

const signerData = await getSignerInfo(transactionConfig.signers);

// Use the signer information to create the transaction

const transaction = new Transaction(signerData, transactionConfig);

return transaction;

};

To transfer a signer to our safe, we can create a new transaction that contains the signer’s public key:

const mySafeInstance = await mySafe.createTransaction({

type: "transaction",

inputs: [],

outputs: [], // Add output if any

// Add a signer to the transaction

signers: [newSigner.publicKey],

});

In this example, we created a new transaction and added our “newSigner” public key as one of the signers. This allows us to approve transactions with multiple signers.

Putting it all together

If you want to use multiple signers in your safe, you need to create a new instance of the “Safe” class, define the multisig configuration, and then use the code above to create multiple signers. Here’s an example of how to put it all together:

“` javascript

Import { Safe } from ‘@safe-global’;

import getPrivateKeyAndPublicKey from ‘./getPrivateKeyAndPublicKey’;

import { createTransaction } from ‘.

ethereum market order using

Exit mobile version