MakisChristou / erc-4337-examples

A collection of example scripts for working with ERC-4337

Home Page:https://docs.stackup.sh/docs/erc-4337-examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting started

Install dependencies and generate initial config

yarn install
yarn run init

Use the following config and replace the entryPoint and the factory with your deployed contracts

{
  "rpcUrl": "http://localhost:3000",
  "overideBundlerUrl": "http://localhost:4337/rpc",
  "entryPoint": "0x85FeB66007a203eDa0695Ca833A0FFDD7D879787",
  "factory": "0xBcb83afEF0826aAe3F79C44C0A324085E0d09330",
  "signingKey": "",
  "paymaster": {
    "rpcUrl": "https://api.stackup.sh/v1/paymaster/API_KEY",
    "context": {}
  }
}

Get the account address

yarn run simpleAccount address

Deploy

yarn run simpleAccount deploy

Simple VET transfer

yarn run simpleAccount transfer --to 0x94C576C6Fdf76EDdCA1e88e4A0169CDcc23e5539 --amount 0.01

Simple VTHO transfer

yarn run simpleAccount erc20Transfer --token 0x0000000000000000000000000000456E65726779 --to 0x94C576C6Fdf76EDdCA1e88e4A0169CDcc23e5539  --amount 0.00001

Deposit an amount of VTHO to EntryPoint from SA

yarn run simpleAccount vthoDeposit  --amount 0.001 

Withdraw all SA's VTHO from EntryPoint

yarn run simpleAccount vthoWithdrawAll

Get SA deposit info from EntryPoint

yarn run simpleAccount getDepositInfo

Server

yarn run server

Deploy

curl -X POST \
-H "Content-Type: application/json" \
-d '{"options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/deploy

Simple VET transfer

curl -X POST \
-H "Content-Type: application/json" \
-d '{"to": "0x94C576C6Fdf76EDdCA1e88e4A0169CDcc23e5539", "amount": "0.01", "options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/transfer

Simple VTHO transfer

curl -X POST \
-H "Content-Type: application/json" \
-d '{"token": "0x0000000000000000000000000000456E65726779", "to": "0x94C576C6Fdf76EDdCA1e88e4A0169CDcc23e5539", "amount": "0.00001", "options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/erc20Transfer

Deposit an amount of VTHO to EntryPoint from SA

curl -X POST \
-H "Content-Type: application/json" \
-d '{"amount": "0.001", "options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/vthoDeposit

Withdraw all SA's VTHO from EntryPoint

curl -X POST \
-H "Content-Type: application/json" \
-d '{"options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/vthoWithdrawAll

Get SA deposit info from EntryPoint

curl -X POST \
-H "Content-Type: application/json" \
-d '{"options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/getDepositInfo

Get SA VET balance

curl -X POST \
-H "Content-Type: application/json" \
-d '{"options": {"dryRun": false, "withPM": false}}' \
http://localhost:3001/balance

About

A collection of example scripts for working with ERC-4337

https://docs.stackup.sh/docs/erc-4337-examples

License:MIT License


Languages

Language:TypeScript 71.1%Language:JavaScript 28.9%