Skip to content

Meta Transactionの知識を習得するために作成したサンプルコード

Notifications You must be signed in to change notification settings

nabeo114/eth-forwarder-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Eth Forwarder Sample

eth-forwarder-sample demonstrates ERC-2771 (Meta-Transactions) using Forwarder and Recipient smart contracts. It is inspired by the MetaTxDemo project, which provides additional examples of meta-transactions.

Overview

This project serves as a sample for learning Ethereum meta-transactions. It deploys two smart contracts, Forwarder and Recipient, that conform to the ERC-2771 standard.

Installation

  1. Clone the repository:

    git clone https://github.com/nabeo114/eth-forwarder-sample.git
    cd eth-forwarder-sample
  2. Install dependencies:

  • Hardhat:

    cd hardhat
    npm install
  • Frontend:

    cd ../frontend
    npm install
  1. Configure the .env file:

    Create a .env file in the hardhat directory with the following variables:

    INFURA_API_KEY=your_infura_api_key_here
    ACCOUNT_PRIVATE_KEY=your_private_key_here
    KEYSTORE_PASSWORD=your_keystore_password_here

    Note:

    • The ACCOUNT_PRIVATE_KEY will be used to deploy the Forwarder and Recipient contracts and also act as the relayer for meta-transactions.
    • Contracts are deployed on the Polygon Amoy testnet. Ensure the ACCOUNT_PRIVATE_KEY is funded with MATIC tokens using the Polygon Faucet.
    • INFURA_API_KEY: Obtain this from Infura after creating an account.
    • KEYSTORE_PASSWORD: Used to encrypt the keystore; you can set this to any desired string.

Usage

  1. Create accounts and deploy the smart contracts:

    cd hardhat
    npm run account
    npm run deploy
  2. Set up the frontend:

    cd ../frontend
    npm start

Demo Features

  • Relayer and User Accounts: The demo creates one relayer account (using the ACCOUNT_PRIVATE_KEY in the .env file) and two user accounts.
  • ERC20 Token Minting: ERC20 tokens can be minted to user accounts.
  • Token Transfers: Transfers between user accounts are performed by the relayer account.

About

Meta Transactionの知識を習得するために作成したサンプルコード

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published