Code Monkey home page Code Monkey logo

axiom-paymaster's Introduction

Axiom Power User Paymaster

Introduction

This repo is an example on how you can build an ERC-4337 Paymaster poweredby Axiom. To learn more about Axiom, check out the developer docs at docs.axiom.xyz or join the developer Telegram.

Installation

This repo contains both Foundry and Javascript packages. To install, run:

forge install
pnpm install     # or `npm install` or `yarn install`

For installation instructions for Foundry or a Javascript package manager (npm, yarn, or pnpm), see Package Manager Installation.

Copy .env.example to .env and fill in your JSON-RPC provider URL. If you'd like to send transactions from a local hot wallet on testnet also add a Sepolia private key.

โš ๏ธ WARNING: Never use your mainnet private key on a testnet! If you use this option, make sure you are not using the same account on mainnet.

Test

To run Foundry tests that simulate the Axiom integration flow, run

forge test -vvvv

Send a Query on-chain

To send a Query on Sepolia testnet (requires PRIVATE_KEY_SEPOLIA in .env file), run

npx tsx app/index.ts 

CLI Cheatsheet

# compile
npx axiom circuit compile app/axiom/average.circuit.ts --provider $PROVIDER_URI_SEPOLIA

# prove
npx axiom circuit prove app/axiom/average.circuit.ts --sourceChainId 11155111 --provider $PROVIDER_URI_SEPOLIA

# get parameters to send a query to Axiom using sendQuery
npx axiom circuit query-params <callback contract address> --refundAddress <your Sepolia wallet address> --sourceChainId 11155111 --provider $PROVIDER_URI_SEPOLIA

Package Manager Installation

Install npm or bun or yarn or pnpm:

# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.bashrc  # or `source ~/.zshrc` on newer macs

# Install latest LTS node
nvm install --lts

# Install pnpm
npm install -g pnpm
pnpm setup
source ~/.bashrc  # or `source ~/.zshrc` on newer macs

Install Foundry. The recommended way to do this is using Foundryup:

curl -L https://foundry.paradigm.xyz | bash
foundryup

Deploy

To deploy, run the following command substituting RPC_URL and ENTRY_POINT_ADDRESS

Consider using --priority-gas-price to set a lower than maximum priority gas price E.g. --priority-gas-price 10000

EntryPoint

forge script script/DeployEntryPoint.s.sol --fork-url <RPC_URL> --broadcast

AccountFactory

forge script script/DeployAccountFactory.s.sol <ENTRY_POINT_ADDRESS> --sig "run(address)" --fork-url <RPC_URL> --broadcast

AxiomPaymaster

Value that can be used for test purposes MAX_REFUND_PER_BLOCK=10000000000000

forge script script/DeployAxiomPaymaster.s.sol <ENTRY_POINT_ADDRESS> <MAX_REFUND_PER_BLOCK> --sig "run(address,uint256)" --fork-url <RPC_URL> --broadcast

FundPaymaster

forge script script/FundPaymaster.s.sol <ENTRY_POINT_ADDRESS> <PAYMASTER_ADDRESS> <AMOUNT> --sig "run(address,address,uint256)" --fork-url <RPC_URL> --broadcast

If you are deploying to your local node, you must first start the node by running anvil in a separate terminal window

axiom-paymaster's People

Contributors

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