ERC 4337, also known as the Ethereum Improvement Proposal (EIP) 4337 or the Account Abstraction, is designed to facilitate smart contract-based user accounts. The concept seeks to make it easier for users to interact with the Ethereum blockchain without the need for Ether (ETH) to cover transaction fees. However, ERC 4337 doesn't directly relate to multisig wallets implementation.
To create a basic multisignature wallet (or account) on Ethereum, we can use the MultiSigWallet smart contract by Gnosis. Here's a step-by-step guide:
- Install dependencies:
You'll need Node.js and NPM (Node Package Manager).
- Download the MultiSigWallet repository:
In your terminal, clone the Gnosis MultiSigWallet repository by running:
git clone https://github.com/gnosis/MultiSigWallet.git
This will create a local copy of the MultiSigWallet repository. Go to the downloaded directory:
cd MultiSigWallet
- Install the required packages:
In the MultiSigWallet directory, install the required packages by running:
npm install
- Deploy the multisig wallet:
To deploy the multisig wallet on the Ethereum network, you'll need an Ethereum client (like Geth or OpenEthereum) and the Truffle framework for smart contract deployment. You can install Truffle with:
npm install -g truffle
- Configure Truffle:
Create a new file named truffle-config.js and configure it with your Ethereum deployment settings. It should look something like this:
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*", // Match any network id
gas: 4712388
}
},
compilers: {
solc: {
version: "0.4.25"
},
},
};
In this example, we are deploying on a local Ethereum development network.
- Deploy the multisig wallet contract:
Execute the following command from the terminal in the MultiSigWallet directory:
truffle migrate --network development
This will deploy your multisig wallet on the Ethereum network.
- Create a multisig wallet instance:
After deployment, obtain the contract address and ABI (Application Binary Interface), which are essential to interact with the contract. Instantiate a Web3 instance and create a multisig wallet instance:
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8545');
const multiSigWalletAbi = [ /* contract ABI */ ];
const multiSigWalletAddress = '0x...'; // Contract address
const multiSigWallet = new web3.eth.Contract(multiSigWalletAbi, multiSigWalletAddress);
- Customize the multisig wallet:
Customize the multisig wallet by configuring signer addresses (the Ethereum accounts that can sign transactions) and the required number of confirmations to execute transactions:
const signers = [
'0x...', // Signer 1's address
'0x...', // Signer 2's address
// Add more signers if needed
];
const requiredConfirmations = 2;
const deploymentAccount = '0x...'; // The account to deploy the custom multisig wallet
const customMultisigWallet = await multiSigWallet.methods
.createMultiSigWallet(signers, requiredConfirmations)
.send({ from: deploymentAccount, gas: 300000 });
const customMultisigWalletAddress = customMultisigWallet.events.WalletCreated.returnValues[0];
The createMultiSigWallet function creates a new multisig wallet that requires the specified number of confirmations from the signer accounts to execute a transaction. The custom wallet's address is obtained from the event emitted.
This guide covers the basic setup of a multisignature wallet on the Ethereum network using the Gnosis MultiSigWallet. To interact with the multisignature wallet further, refer to the smart contract documentation and utilize its functions to manage transactions.