Smart contracts for ERC-4337 account and paymaster implementations.
This repository builds upon the following frameworks and libraries:
- Hardhat: compile, run and test smart contracts
- TypeChain: generate TypeScript bindings for smart contracts
- Ethers: renowned Ethereum library and wallet implementation
- Solhint: code linter
- Solcover: code coverage
- Prettier Plugin Solidity: code formatter
The account-abstraction directory in this repository uses git submodules to include
eth-infinitism/account-abstraction as a workspace. Make sure to
include the --recurse-submodules
flag in your git clone command.
git clone --recurse-submodules https://github.com/AAStarCommunity/basic_paymaster_contract.git
This repository comes with sensible default configurations in the following files:
├── .editorconfig
├── .eslintignore
├── .eslintrc.yml
├── .gitignore
├── .prettierignore
├── .prettierrc.yml
├── .solcover.js
├── .solhint.json
└── hardhat.config.ts
This repository is IDE agnostic, but for the best user experience, you may want to use it in VSCode alongside Nomic Foundation's Solidity extension.
All contracts will be linted and tested on every push and pull request made to the main
branch.
Below are some useful commands for development.
Before being able to run any command, you need to create a .env
file and set your environment variables. You can
follow the example in .env.example
.
By default, all non test contract deployments will use the BIP-39 compatible mnemonic set in the .env
file. If you
don't already have a mnemonic, you can use this website to generate one.
If you do not want to use your mnemonic to deploy contracts, you can also use local providers like
frame to connect this repository to an alternative signing method (e.g. hardware
wallet). Make sure to set DEPLOY_WITH_LOCAL_RPC
to the correct url in your .env
file. This is the preferred method
for security.
ℹ️ Note: If you are using
DEPLOY_WITH_LOCAL_RPC
make sure the local provider is configured to the correct network. If using frame, make sure the dApp's default network is set to the correct chain.
cp .env.example .env
Then, proceed with installing dependencies:
yarn install
Compile the smart contracts with Hardhat:
yarn run compile
Compile the smart contracts and generate TypeChain bindings:
yarn run typechain
Run the tests with Hardhat:
yarn run test
Lint the Solidity code:
yarn run lint:sol
Lint the TypeScript code:
yarn run lint:ts
Generate the code coverage report:
yarn run coverage
See the gas usage per unit test and average gas per method call:
REPORT_GAS=true yarn run test
Delete the smart contract artifacts, the coverage reports and the Hardhat cache:
yarn run clean
Deploy the contracts to Hardhat Network:
yarn run deploy:VerifyingPaymaster
Distributed under the GPL-3.0 License. See LICENSE for more information.