Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Abstract Paymasters Demo

Build and deploy a paymaster smart contract that can sponsor the gas fees of transactions for other accounts on Abstract.

Local Development

  1. Get a copy of the paymasters example directory from the Abstract Examples repository:

    mkdir -p paymasters && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C paymasters examples-main/paymasters && cd paymasters
  2. Install dependencies.

    yarn
  3. Use Hardhat to run yarn compile and compile the MyPaymaster smart contract.

Deploy & Use the Paymaster

To demo the code, deploy and submit a gas-sponsored transaction from a wallet:

  1. Compiling the contracts.

    yarn compile
  2. Create a new Hardhat configuration variable for your wallet private key.

    When prompted, enter the private key of the wallet you want to use to deploy the contract. It is strongly recommended to use a new wallet for this purpose.

    npx hardhat vars set WALLET_PRIVATE_KEY
  3. Deploy the MyPaymaster contract.

    The defaultNetwork inside hardhat.config.ts is set to abstractTestnet. You will need testnet ETH from a faucet in your wallet to deploy the contract to Abstract.

    yarn deploy
  4. Take the outputted Contract address and paste it on line 11 of the interact.ts file:

    const CONTRACT_ADDRESS = "<your-deployed-contract-address-here>";
  5. Interact with the deployed contract.

    yarn interact

    This will submit a transaction to the network that your paymaster will sponsor the gas fees for.

Using a local node with Docker

  1. Install the ZKsync CLI

    yarn global add zksync-cli
  2. For local development, ensure Docker is installed and running.

    docker --version
    docker info
  3. For local development, run an "In Memory node".

    zksync-cli dev start
  4. Set the hardhat default network to inMemoryNode in hardhat.config.ts.

    defaultNetwork: "inMemoryNode",
  5. Use the RICH_WALLETS array available in the utils.ts file to access accounts loaded with funds on the local node.

Useful Links