Parameters

This document provides detailed information about the various parameters used in the 0xGassless SDK functions and configuration. Understanding these parameters is crucial for correctly utilizing the SDK and configuring your environment.

Configuration Parameters

These parameters are used to configure the SDK during initialization.

network

  • Description: Specifies the blockchain network to use.

  • Type: String

  • Example Values: base, ropsten

  • Usage:

    {
      "network": "base"
    }

rpcUrl

  • Description: The RPC URL for connecting to the blockchain.

  • Type: String

  • Example Value: https://base.infura.io/v3/YOUR_INFURA_PROJECT_ID

  • Usage:

    {
      "rpcUrl": "https://base.infura.io/v3/YOUR_INFURA_PROJECT_ID"
    }

bundlerUrl

  • Description: The URL of the 0xGassless bundler service.

  • Type: String

  • Example Value: https://bundler.0xgassless.com/{chainId}

  • Usage:

    {
      "bundlerUrl": "https://bundler.0xgassless.com/1"
    }

paymasterUrl

  • Description: The URL of the 0xGassless Paymaster service.

  • Type: String

  • Example Value: https://paymaster.0xgassless.com/v1/{chainId}/rpc

  • Usage:

    {
      "paymasterUrl": "https://paymaster.0xgassless.com/v1/1/rpc"
    }

privateKey

  • Description: The private key of the account to use for signing transactions.

  • Type: String

  • Example Value: 0xYourPrivateKey

  • Usage:

    {
      "privateKey": "0xYourPrivateKey"
    }

Transaction Parameters

These parameters are used when sending transactions through the SDK.

to

  • Description: The recipient address of the transaction.

  • Type: String

  • Example Value: 0xRecipientAddress

  • Usage:

    const transaction = {
      to: "0xRecipientAddress"
    };

value

  • Description: The amount of value to send (in wei).

  • Type: String

  • Example Value: 0

  • Usage:

    const transaction = {
      value: "0"
    };

data

  • Description: The data payload for the transaction.

  • Type: String

  • Example Value: 0xYourData

  • Usage:

    const transaction = {
      data: "0xYourData"
    };

Smart Account Parameters

These parameters are used when interacting with Smart Accounts.

moduleAddress

  • Description: The address of the module to add or remove.

  • Type: String

  • Example Value: 0xModuleAddress

  • Usage:

    const moduleAddress = "0xModuleAddress";

accountAddress

  • Description: The address of the Smart Account.

  • Type: String

  • Example Value: 0xSmartAccountAddress

  • Usage:

    const accountAddress = "0xSmartAccountAddress";

ownerAddress

  • Description: The address of the owner of the new Smart Account.

  • Type: String

  • Example Value: 0xOwnerAddress

  • Usage:

    const ownerAddress = "0xOwnerAddress";

factoryAddress

  • Description: The address of the Smart Account Factory contract.

  • Type: String

  • Example Value: 0xFactoryAddress

  • Usage:

    const factoryAddress = "0xFactoryAddress";

Example Configuration

Here is an example of a complete configuration object for initializing the 0xGassless SDK:

{
  "network": "base",
  "rpcUrl": "https://base.infura.io/v3/YOUR_INFURA_PROJECT_ID",
  "bundlerUrl": "https://bundler.0xgassless.com/1",
  "paymasterUrl": "https://paymaster.0xgassless.com/v1/1/rpc",
  "privateKey": "0xYourPrivateKey"
}

Example Transaction

Here is an example of a transaction object used with the sendTransaction method:

{
  "to": "0xRecipientAddress",
  "value": "0",
  "data": "0xYourData"
}

Example Smart Account Interaction

Adding a Module

const moduleAddress = "0xModuleAddress";
const accountAddress = "0xSmartAccountAddress";

gassless.addModule(moduleAddress, accountAddress)
  .then(response => console.log("Module added:", response))
  .catch(error => console.error("Failed to add module:", error));

Removing a Module

const moduleAddress = "0xModuleAddress";
const accountAddress = "0xSmartAccountAddress";

gassless.removeModule(moduleAddress, accountAddress)
  .then(response => console.log("Module removed:", response))
  .catch(error => console.error("Failed to remove module:", error));

Deploying a Smart Account

const ownerAddress = "0xOwnerAddress";
const factoryAddress = "0xFactoryAddress";

gassless.deploySmartAccount(ownerAddress, factoryAddress)
  .then(smartAccount => console.log("Smart Account deployed:", smartAccount))
  .catch(error => console.error("Failed to deploy Smart Account:", error));

Retrieving Smart Account Details

const accountAddress = "0xSmartAccountAddress";

gassless.getSmartAccount(accountAddress)
  .then(accountDetails => console.log("Smart Account details:", accountDetails))
  .catch(error => console.error("Failed to retrieve Smart Account details:", error));