This guide will help you set up your environment and perform your first transaction using 0xGassless.
Setting Up Your Environment
Step 1: Install the SDKs
First, ensure you have installed the 0xGassless SDK:
npminstall@0xgasless/smart-account
Step 2: Configure the Bundler and Paymaster
Replace {chainId} with your actual chain ID:
Bundler URL:
https://bundler.0xgasless.com/{chainId}
Paymaster URL:
https://paymaster.0xgasless.com/v1/{chainId}/rpc
Step 3: Initialize the SDK
Here's an example of how to initialize the SDK with your configuration:
import { PaymasterMode, createBundler, createSmartAccountClient,} from"@0xgasless/smart-account";import { ethers } from"ethers"; //ethers@5.7.2constchainId=8453constbundlerUrl=`https://bundler.0xgasless.com/${chainId}`; // Replace '1' with your chainIdconstpaymasterUrl=`https://paymaster.0xgasless.com/v1/${chainId}/rpc`; // Replace '1' with your chainIdconstrpc=""constprivateKey=""constprovider=newethers.providers.JsonRpcProvider(rpc);constwallet=newethers.Wallet(privateKey, provider);constsmartWallet=awaitcreateSmartAccountClient({ signer: wallet!, paymasterUrl: PaymasterUrl, bundlerUrl: bundlerUrl, chainId: chainId,});// Initialize and use your smart account as needed
First Transaction
Once your environment is set up, you can execute your first gasless transaction.
Step 1: Create a Transaction
Create a transaction object with the necessary details:
consttransaction= { to:'0xRecipientAddress',// Replace with the recipient's address value:'1000000000000000000',// Amount in wei (1 ETH in this example) data:'0x',// Optional data payload};
Step 2: Send the Transaction
Use the smartAccount object to send the transaction:
By following these steps, you should be able to set up your environment and execute your first gasless transaction using 0xGassless. For more detailed usage and advanced features, refer to the other sections of this documentation.