Coder Social home page Coder Social logo

zksync-aa-wallet-paymaster's Introduction

Overview

An implementation of zkSync's account abstraction and paymaster with a batched transaction and daily spending limit feature. You can find and explore more details about zkSync and those features in the documentation below.

Developments

Account

zkSync Account Abstraction contract wallet. Architecture is inspired by Gnosis Safe. Account.sol and BaseAccount.sol.

Batch transaction

Account.sol has multicall feature so that it can facilitate batched transactions with _executeBatchTransaction where for-loop utilizes targets[] and methods[] data which respectively store contract addresses and functions. As such, in a batched transaction, msg.data isn't single hexlified method data but a batched multiple transaction data encoded with AbiCoder.encode() method.

Sponsored Transaction

As zksync-unique approvalBased paymaster flow is supported, MyPaymaster.sol allows the account to both proceed gas-sponsored transcations and gas payments in ERC20. Also, it calculates the actual gas cost in ERC20 terms with the price data retrieved from chainlink oracle.

Spending limit

The daily-spending limit feature can be enabled for the account, where it refuses the account to spend in ETH/ERC20 more than a configured limit amount.

!Currently, deploy and test folders in this repo don't work as they haven't been updated for new contracts

Deployment & Test

git clone [email protected]:porco-rosso-j/zksync-aa-wallet-paymaster.git
  • Enter the repo and install dependencies.
cd zksync-aa-wallet-paymaster
npm i
  • To set-up local environment, Docker and docker-compose should be installed.
    If they are not installed on your computer: Install.

  • To run zkSync local chain, do:

git clone https://github.com/matter-labs/local-setup.git
cd local-setup
./start.sh

*check details and common errors for running local zksync chain here.

  • compile:
npm run compile
  • additional configuration: add .env file touch .env and add NODE_ENV=test in it.

  • deploy:

npx hardhat deploy-zksync --script deploy/<file-name>.ts

example:

npx hardhat deploy-zksync --script deploy/deploy-paymaster.ts
  • test:
npm run test:integration

zksync-aa-wallet-paymaster's People

Contributors

porco-rosso-j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.