Installation

To get started with 0xGassless, follow the installation steps below.

Prerequisites

Before installing, ensure you have the following:

  • Node.js (version 14 or higher)

  • npm (version 6 or higher)

Installation Steps

Step 1: Install prerequisites

The 0xgasless SDK is compatible with both viem and ethers

npm install ethers

or

npm install viem

Step 2: Install the Smart Account SDK

Additionally, you may need the Smart Account SDK:

npm install @0xgasless/smart-account

Step 3: Configure the Bundler and Paymaster

You need to configure the Bundler and Paymaster URLs for your specific chain. Replace {chainId} with the actual chain ID you are working with.

  • Bundler URL:

    https://bundler.0xgasless.com/{chainId}
  • Paymaster URL:

    https://paymaster.0xgasless.com/v1/{chainId}/rpc

Example Configuration

Here is an example of how you might set up the configuration in your application:

import {
	PaymasterMode,
	createBundler,
	createSmartAccountClient,
} from "@0xgasless/smart-account";
import { ethers } from "ethers"; //ethers@5.7.2

const chainId = 8453
const bundlerUrl = `https://bundler.0xgasless.com/${chainId}`; // Replace '1' with your chainId
const paymasterUrl = `https://paymaster.0xgasless.com/v1/${chainId}/rpc`; // Replace '1' with your chainId

const rpc = ""
const privateKey = ""
const provider = new ethers.providers.JsonRpcProvider(rpc);
const wallet = new ethers.Wallet(privateKey, provider);

const smartWallet = 
await createSmartAccountClient({
  signer: wallet!,
  paymasterUrl: PaymasterUrl,
  bundlerUrl: bundlerUrl,
  chainId: chainId,
});
// Initialize and use your smart account as needed

For detailed instructions, see Prerequisites and Installation Steps.

Last updated