Code Monkey home page Code Monkey logo

paymaster-bundler-examples's Introduction

This repo has code examples on how to sponsor a mint for a Knight Warriors NFT on Base Sepolia using Coinbase Cloud's Paymaster & Bundler.

We currently have examples for the following SDKs, but contributions are always welcome! See Contributing for more details.

Getting Started

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

1. Clone this repo locally

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

2. Set up environment variables

  • Create your Base Node RPC URL

    • Navigate to https://coinbase.com/cloud/products/base/rpc
    • Sign up for a Coinbase Cloud account, if you don't have one already
    • Create a project, and select Base Sepolia
    • Click "Activate" on the Paymaster & Bundler modal
    • Copy your RPC endpoint, and paste it into config.json as the rpc_url variable.
  • Add a signer

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

    • Since the NFT mint 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
      • To generate a new key pair, run cast wallet new
    • Copy your private key, and paste it into config.json as the private_key variable

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

Example for Alchemy

cd examples/alchemy

4. Install the dependencies with yarn

yarn

5. Run the example

yarn dev

6. See your sponsored transaction live!

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

Minting to 0xF19CEA17462220437000F459f721e3e393bd1fc9
Waiting for transaction...
 โ›ฝ Successfully sponsored gas for mintTo transaction with Coinbase Cloud!
 ๐Ÿ” View on Etherscan: https://sepolia.basescan.org/tx/0xe51e9bf6fea0dfecfcbf7168bcc7da2c833ad0dcac5651940953a89857674885
โœจ  Done in 5.66s.

paymaster-bundler-examples's People

Contributors

0xalec 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.