Coder Social home page Coder Social logo

paymaster-bundler-examples's Introduction

This repo has code examples on how to request tokens from an ERC20 token [SWING] faucet (https://basescan.org/address/0xcC7817DCc0965DDE3B4a9340ec35A21b23393013) on Base using Coinbase Developer Platform's Paymaster & Bundler.

I currently have one example using the pimlico SDK, but contributions are always welcome!

Supported SDKs

Supported Account Types

Compatibility

SDK Simple Safe Kernel
permissionless.js

Getting Started

Prerequisites: you'll need to have node and yarn installed.

1. Clone this repo locally

git clone https://github.com/CPix18/paymaster-bundler-examples.git

2. Get into the right folder

cd paymaster-bundler-examples

3. Set up environment variables

  • Copy the env example

cp .env.example .env
  • Install dotenv

yarn
  • This will setup dotenv to load the env file for private values

  • Get your Node RPC URL

    • Navigate to https://www.coinbase.com/developer-platform/products/base-node
    • Sign up for a Coinbase Developer Platform account, if you don't have one already.
    • Under the Build Onchain section in the Portal, select Node
    • In the dropdown on the top right of Configuration, select Base Mainnet
    • Copy your RPC endpoint, and paste it into .env as the RPC_URL variable.
      • The RPC URL should look like https://api.developer.coinbase.com/rpc/v1/base/<api_key>
  • Add a signer

    You'll need to add a private key to initialize and sign for your ERC-4337 smart contract account

    • Since the faucet request is free and gas will be sponsored by our Paymaster, you can use a new account without any funds
    • You can create a new private key with Foundry
      • To install Foundry, run curl -L https://foundry.paradigm.xyz | bash in Terminal for mac users
      • To generate a new key pair, run cast wallet new
    • Copy your private key, and paste it into .env as the PRIVATE_KEY variable
    • YOU CAN ALSO JUST USE A NEW PRIVATE KEY GENERATED FROM A WALLET APP

4. Navigate to the directory of the SDK you want to run the example with.

Example for swing

cd examples/pimlico

5. Install the dependencies with yarn

yarn

6. Run the example

yarn dev

7. See your sponsored transaction live!

You should receive an Etherscan link with your sponsored transaction in the terminal output. Example

Minting to 0x923a5B9864726a67E1B2a0839c9b698b84dD4B80
Waiting for transaction...
 ⛽ Successfully sponsored gas for mintTo transaction with Coinbase Developer Platform!
 🔍 View on Etherscan: https://basescan.org/tx/0x94e27c21b8f8e3a288cbeff022a6c921aa49d7a945e340b05c3141a72da63183
✨  Done in 5.66s.

paymaster-bundler-examples's People

Contributors

cpix18 avatar 0xalec avatar cfluke-cb avatar derekchiang avatar alex-hu-1 avatar chunter-cb 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.