diff --git a/README.md b/README.md index 534f0fd..603555b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Version](https://img.shields.io/npm/v/@defi-wonderland/hardhat-account-abstraction?label=Version)](https://www.npmjs.com/package/@defi-wonderland/hardhat-account-abstraction) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/defi-wonderland/hardhat-account-abstraction/blob/main/LICENSE) + # Hardhat Account Abstraction A plugin to send sponsored transactions utilizing account abstraction! @@ -5,7 +8,7 @@ A plugin to send sponsored transactions utilizing account abstraction! ## What -This plugin sponsors any transaction the user sends through the power of account abstraction. Through seemless integration after the configuration is set just submit any transaction, and you can see it get mined on the testnets without costing the signer any gas! +This plugin sponsors any transaction the user sends through the power of account abstraction. Through seamless integration after the configuration is set just submit any transaction, and you can see it get mined on the testnets without costing the signer any gas! ## Installation @@ -36,6 +39,39 @@ import "@defi-wonderland/hardhat-account-abstraction"; - [@nomicfoundation/hardhat-ethers](https://github.com/NomicFoundation/hardhat/tree/main/packages/hardhat-ethers) - [@nomicfoundation/hardhat-viem](https://github.com/NomicFoundation/hardhat/tree/main/packages/hardhat-viem) +## Quick Start + +1. Install the plugin from the [installation guide](#installation) + +1. Next we will need to get a bundler and paymaster to sponsor our transactions, for this example we will use [pimlico](https://docs.pimlico.io/) but this will work with any bundler and supported paymaster + +1. Navigate to your [pimlico dashboard](https://dashboard.pimlico.io/apikeys) and get your api key + +1. Now we can add this to our config and we should be good to go, for more custom configuration see [here](#configuration) + +```typescript +import { HardhatUserConfig } from 'hardhat/config'; +import '@nomicfoundation/hardhat-ethers'; // Can also be viem if you are using viem +import '@defi-wonderland/hardhat-account-abstraction'; + +const config: HardhatUserConfig = { + solidity: '0.8.19', + defaultNetwork: 'sepolia', + networks: { + sepolia: { + url: "", + accounts: [""], + accountAbstraction: { + bundlerUrl: "https://api.pimlico.io/v1/sepolia/rpc?apikey=", + paymasterUrl: "https://api.pimlico.io/v2/sepolia/rpc?apikey=", + } + } + } +}; + +export default config; +``` + ## Tasks @@ -80,6 +116,16 @@ const config: HardhatUserConfig = { | `smartAccount` | Address of a smart account to use in your scripts | No | Will deploy one for you | | `policyId` | The policy id to use if your paymaster has one | No | No default | +### How does default smart account deployment work? + +When you use a `PRIVATE_KEY` and no set `smartAccount` in the config we will deploy a smart account for you, your signer will be the owner of the smart account, however the sender address for all interactions will be the `smartAccount` not the signer. +
+ +This smart contract that gets deployed acts as a wallet that will be used to make transactions, all transactions require your signer's signature, to go deeper into the ERC-4337 standard [check out this article from cointelegraph](https://cointelegraph.com/learn/account-abstraction-guide-to-ethereums-erc-4337-standard). + +
+We use your signer address as a salt when deploying the smart account so it will be unique to your signer and reuseable no matter how many times you run the scripts. + ### Supported Paymaster Types The list of paymasters we currently support @@ -98,19 +144,25 @@ If you would like to add support for a new paymaster check out the [contributors 1. The SimpleAccount Factory is deployed to the address `0x9406cc6185a346906296840746125a0e44976454` or alternatively entered as an optional parameter in the config 1. The [CreateXFactory](https://github.com/pcaversaccio/createx) needs to be deployed to its standard address +
+ #### Currently the list of supported chains is, but not limited to the following: 1. Ethereum Sepolia -1. Ethereum Goerli 1. Polygon Mumbai -1. Base Goerli -1. Optimism Goerli -1. Arbitrum Goerli +1. Base Sepolia +1. Optimism Sepolia +1. Arbitrum Sepolia +1. Mantle Testnet +1. Avalanche Testnet (Fuji) +1. Binance Smart Chain Testnet + +And more! ## Usage -> **⚠ WARNING: Any non-zero msg.value call will not work as intended as paymaster's dont sponsor this value, in order to use native transfers or interact with payable functions you will need the native token of your chain in the smart account wallet beforehand** +> **⚠ WARNING: Any non-zero msg.value call will not work as intended as paymaster's don't sponsor this value, in order to use native transfers or interact with payable functions you will need the native token of your chain in the smart account wallet beforehand** After you have setup the configuration for the `accountAbstraction` and you are using a network that has them enable you are good to go, you can right a simple script below and your transactions will be mined on the testnet that you have configured! @@ -129,7 +181,7 @@ Deploying contracts works just as any other transaction would, however due to th - **Ownable contracts** - We do support ownable contracts and the default `owner` of your contract will be the smart account you deployed with, the only condition is you must have a `transferOwnership(address)` function to make this work, if you have a custom implementation of `Ownable` and dont instantiate `owner` as `msg.sender` in the constructor it will also work. + We do support ownable contracts and the default `owner` of your contract will be the smart account you deployed with, the only condition is you must have a `transferOwnership(address)` function to make this work, if you have a custom implementation of `Ownable` and don't instantiate `owner` as `msg.sender` in the constructor it will also work. - **Contract addresses in scripts** @@ -217,7 +269,7 @@ If you want to learn how to add support for your own paymaster implementation ch Hardhat Account Abstraction was built with ❤️ by [Wonderland](https://defi.sucks). -Wonderland the largest core development group in web3. Our commit ment is to a financial future that's open, decentralized, and accessible to all. +Wonderland is the largest core development group in web3. Our commitment is to a financial future that's open, decentralized, and accessible to all. [DeFi sucks](https://defi.sucks), but Wonderland is here to make it better.