Skip to content

⛽ Account Abstraction Library for deploying Smart Wallets, allow users to pay Gas Fees in any ERC-20 or even sponsor Gas Fees.

License

Notifications You must be signed in to change notification settings

bytes0xcr6/GasFellow-Account-Abstraction

Repository files navigation

GasFellow - Account-Abstraction Library & CLI Demo for Smart Wallets

GasFellow is an Account Abstraction Library for creating Smart Wallets and paying chain fees in any ERC-20 or even sponsor gas fee for users.

image Example of Transferring 1.000 eUSD and charging 0.00128788 as fee (Refund for Bundler). The Smart Wallet does not own the native chain currency. ArbiScan ERC20 Transfer receipt

Overview

The Smart Wallet is a Solidity smart contract that introduces a new way for users to store value and execute transactions by paying the Gas fees in any ERC20 token or even have fees sponsored by a Bundler. This is an alternative where the only participants are:

  • User (EOA or Key pair to sign transactions)
  • Bundler (EOA to add Transactions on chain, pay Gas Fees & Sponsor gas fees or get refunded in ERC20 token)
  • Smart Wallet Factory (Smart contract to deploy Smart Wallets to a precomputed address by using CREATE2 & salt)
  • Smart Wallet (Smart contract where the User will keep all his assets and privileges)

In this way to use Account Abstraction we do not need an Entry point and a Paymaster, as it is expected for internal use & not for depending of third parties as Bundlers.

👾👽 Try it with a quick Demo using the CLI!

image

🧾 ArbiScan receipt

As always, first get some Native token (ARB) for the Bundler through the Faucet.

IMPORTANT: For this demo, we will use the Arbitrum Goerli testnet. Please, make sure you have set up the .env and have enough Test ARB in the Bundler´s Balance.

Prerequisites

  • EVM development environment. (e.g., Hardhat)
  • RPC Provider. (e.g., Infura or public Provider)
  • Ethers.
  • Node.js and npm.

Installation

  1. Clone the repository:

    git clone https://github.com/CristianRicharte6/GasFellow-Account-Abstraction.git
    cd GasFellow-Account-Abstraction
    
  2. Install dependencies:

    npm install
  3. Start the CLI

    npm run "demo"

Setting up Environments

Follow the .env.example file. It is set up for deploying and execution in the Arbitrum Goerli Chain, but it can be used in any other EVM chain. Take into account to update the necessary variables.

✍️ Features

  • Account Abstraction: Users can interact with the blockchain without holding native Cryptocurrency.
  • Flexible Fee Payment: Execute transactions and pay transaction fees in any ERC20 token.
  • Signature Verification: Ensures secure and authenticated transaction execution.
  • Gas-Efficient Fee Calculation: Efficiently calculates and handles fee payments.
  • Multiple Transaction Execution: Execute single or batch transactions seamlessly.
  • CBDC Deployment: Deploy a CBDC for testing purposes. (Already deployed)

🏄‍♀ Getting Started

Sources

  • UserOp-signer: Library to get Call Data, Hash Transaction Data and Sign transaction Data by the Smart Wallet Owner (EOA). It also verifies that the Tx is correctly signed with the Smart Wallet.

  • SmartWalletFactory: It will help you deploy Smart Wallets with a precomputed address as it uses CREATE2.

  • SmartWallet: It will be the user's account, where the user will hold all their value and from where the user will interact. This smart wallet verifies through the ECDSA (Elliptic Curve Digital Signature Algorithm) that the transaction the Bundler is trying to send has been signed by the Smart Wallet Owner (EOA).

  • CBDC: It is just an example of an ERC20 for paying Fees. You do not need to deploy it if you impersonate accounts during testing.

  • DeployCBDC: Deployment Script for direct deployment of a CBDC.

  • DeployDirectlySmartWallet: Deployment Script for direct deployment of a Smart Wallet, without passing through the Smart Wallet Factory.

  • DeploySmartWallet: Deployment Script for Smart Wallet.

  • DeploySmartWalletFactory: Deployment Script for Smart Wallet Factory.

  • SingleTransferSmartWallet: Example of how to sign and send an ERC20 transaction through the Smart Wallet.

Deployment

Deploy the SmartWallet contract to your desired blockchain using your chosen development environment & setting up the Networks in the config. (e.g., hardhat.config.js)

  1. Deploy the Smart Wallet factory by running deploySmartWalletFactory.js

    npx hardhat run scripts/deploySmartWalletFactory.js --network NETWORK_NAME
    
  2. Create a Smart Wallet for an User by setting and running deploySmartWallet.js

    • Before using, update: SmartWalletFactoryAddress with your deployed SmartWallet Factory & Saltwith your desired Salt number.
    npx hardhat run scripts/deploySmartWallet.js --network NETWORK_NAME

    image ArbiScan Deployment receipt

Provide the necessary deployment parameters, including the contract owner's address, Chainlink price feed address, chain ID, and ERC20 token address for fees & for transferring (It can be the same one too, as in this project sample).

Usage

IMPORTANT: For this demo, we will use the Arbitrum Goerli testnet. Please, make sure you have set up the .env and have enough Test ARB in the Bundler´s Balance.

The Smart Wallet contract allows users to execute transactions and pay fees in ERC20 tokens. Here's a basic example of how to use the contract:

  1. Deploy the Smart Wallet contract.

    Check the Smart Wallet deployment flow diagram.

    deployment

  2. Interact with the contract by calling its functions for single (HandleOp) or batch (HandleOps) transaction execution. This functions can be called by any Bundler or by the Smart Wallet owner. Also, they can choose if they would like to send the Transaction sponsored (The bundler takes care of the gas fees) or not sponsored (The Smart wallet will refund the fees in the ERC20 set for fees).

    Check the Smart Wallet Transaction flow diagram.

    AA transaction flow

Interact with the Smart wallet by signing and sending the Tx on chain. An example of usability is the script singleTransferSmartWallet.js.

  • Before using, update: smartWalletAddress, receiverERC20Address & make sure the Smart Wallet have enough funds for the transfer and for paying the gas fees.
 npx hardhat run scripts/singleTransferSmartWallet.js --network NETWORK_NAME

Provide valid transaction details, including target addresses, call data, and signatures.

For detailed usage instructions and contract functions, refer to the source code and comments.

Verified Smart contracts deployed & Participants (Arbitrum Chain Testnet)

Contributors

Cristian Richarte Gil

[email protected]

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For inquiries and feedback, please open an issue on the GitHub repository.

About

⛽ Account Abstraction Library for deploying Smart Wallets, allow users to pay Gas Fees in any ERC-20 or even sponsor Gas Fees.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published