This project is an implementation of the Account Abstraction proposal (EIP-4337) using Hardhat, a development environment for Ethereum. The project contains two main contracts: EntryPoint
and AccountFactory
This project uses different branches for various stages of development and deployment. Here's a brief explanation of each branch:
This branch is used for local development and testing. It contains all the necessary configurations and scripts to run the project on a local Ethereum network, such as Hardhat Network. This is the branch you should use when you want to develop new features or test existing ones in a local environment.
This branch is specifically for deploying the contracts to the Arbitrum network. It contains the necessary configurations and scripts to deploy the contracts to the Arbitrum testnet or mainnet. Use this branch when you're ready to test your contracts in a testnet environment or when you're ready to deploy to the mainnet.
This branch is used for executing batch transactions on the Arbitrum network. It contains scripts that use the multicall feature of the Arbitrum network to execute multiple contract calls in a single transaction. This is useful for reducing gas costs and simplifying transaction management.
contracts/
: Contains the Solidity contracts for the projectdeploy/
: Contains the deployment scripts for the contractstest/
: Contains the test scripts for the contracts
- Node.js and npm installed on your machine
- Hardhat installed globally or locally in your project. You can install it using
npm install --save-dev hardhat
-
Clone the repository to your local machine using
git clone https://github.com/eludius18/Account-Abastraction-AA-EIP4337.git
-
Navigate to the project directory
-
Install the project dependencies using
npm install
Follow these steps to deploy the contracts:
-
Compile the contracts using
npx hardhat compile
. This step is necessary before you can deploy the contracts -
Deploy the
AccountFactory
contract usingnpx hardhat deploy --network arbitrum --tags AccountFactory
. This deploys theAccountFactory
-
Deploy the
EntryPoint
contract usingnpx hardhat deploy --network arbitrum --tags EntryPoint
. This deploys theEntryPoint
(When using Alchemy Bundler, interactions should be made through its EntryPoint Contract) -
Deploy the
Paymaster
contract usingnpx hardhat deploy --network arbitrum --tags Paymaster
. This deploys thePaymaster
Note: The
--network arbitrum
flag is used to specify that the contracts should be deployed to the Arbitrum Sepolia network that you started in step 1
Before running the scripts, you need to set up your environment variables. Follow these steps:
-
Create a new file in the root of your project named
.env
-
Open the
.env
file and add the following variables:
FACTORY_ADDRESS=<YOUR_ACCOUNT_FACTORY_CONTRACT_ADDRESS>
ENTRYPOINT_ADDRESS=<YOUR_ENTRYPOINT_CONTRACT_ADDRESS> --> When using Alchemy Bundler, interactions should be made through its EntryPoint Contract
PAYMASTER_ADDRESS=<YOUR_PAYMASTER_CONTRACT_ADDRESS>
RPC_URL_ARBITRUM=<YOUR_ARBITRUM_RPC_URL>
PRIVATE_KEY=<YOUR_PRIVATE_KEY>
Follow these steps to execute the scripts:
-
Run the
1-execute.ts
script usingnpx hardhat run --network arbitrum scripts/1-execute.js
. This script interacts with the deployed contracts for the first execution. -
Add
ACCOUNT_ADDRESS
to the.env
file. The value forACCOUNT_ADDRESS
should be theSender
address logged to the console when executing the previous step. It should look like this:ACCOUNT_ADDRESS=<YOUR_ACCOUNT_ADDRESS>
.
You may want to run the nonceAccount.ts
script for getting the nonce. You can do this by running:
npx hardhat run --network arbitrum scripts/nonceAccount.ts
You may want to check the balance of the deployed contracts. You can do this by running the accountBalance.ts
script:
npx hardhat run --network arbitrum scripts/accountBalance.ts
Contributions are welcome! Please feel free to submit a pull request