Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: contributors section, typos #74

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 60 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[![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!


## 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

Expand Down Expand Up @@ -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: "<RPC_URL>",
accounts: ["<PRIVATE_KEY>"],
accountAbstraction: {
bundlerUrl: "https://api.pimlico.io/v1/sepolia/rpc?apikey=<API_KEY>",
paymasterUrl: "https://api.pimlico.io/v2/sepolia/rpc?apikey=<API_KEY>",
}
}
}
};

export default config;
```

## Tasks


Expand Down Expand Up @@ -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.
<br>

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).

<br>
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
Expand All @@ -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

<br>

#### 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!

Expand All @@ -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**

Expand Down Expand Up @@ -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.

Expand Down
Loading