API Documentation

This document provides detailed information on the 0xGassless API, including available functions, methods, parameters, and example code snippets. The 0xGassless API allows developers to interact seamlessly with the platform to manage gasless transactions, configure modules, and more.

Overview

The 0xGassless API is designed to facilitate integration with the 0xGassless ecosystem, enabling developers to leverage gasless transactions and other features. This API documentation covers the primary methods and their usage.

Functions and Methods

initialize

Initializes the 0xGassless SDK with the provided configuration.

Parameters:

  • config (Object): Configuration object containing necessary parameters.

Example:

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

const gassless = initialize(config);

sendTransaction

Sends a gasless transaction through the 0xGassless network.

Parameters:

  • transaction (Object): The transaction object containing the necessary details.

    • to (String): The recipient address.

    • value (String): The amount of value to send.

    • data (String): The data payload for the transaction.

Example:

const transaction = {
  to: "0xRecipientAddress",
  value: "0",
  data: "0xYourData"
};

gassless.sendTransaction(transaction)
  .then(response => console.log("Transaction sent:", response))
  .catch(error => console.error("Transaction failed:", error));

getTransactionStatus

Retrieves the status of a specific transaction.

Parameters:

  • transactionHash (String): The hash of the transaction to query.

Example:

const transactionHash = "0xYourTransactionHash";

gassless.getTransactionStatus(transactionHash)
  .then(status => console.log("Transaction status:", status))
  .catch(error => console.error("Failed to retrieve status:", error));

getBalance

Fetches the balance of an account.

Parameters:

  • address (String): The address of the account to query.

Example:

const address = "0xYourAccountAddress";

gassless.getBalance(address)
  .then(balance => console.log("Account balance:", balance))
  .catch(error => console.error("Failed to retrieve balance:", error));

Parameters

Configuration Parameters

  • network (String): The blockchain network to use (e.g., base, ropsten).

  • rpcUrl (String): The RPC URL for connecting to the blockchain.

  • bundlerUrl (String): The URL of the 0xGassless bundler service.

    "bundlerUrl": "https://bundler.0xgasless.com/{chainId}"
  • paymasterUrl (String): The URL of the 0xGassless Paymaster service.

    "PaymasterUrl": "https://paymaster.0xgassless.com/v1/{chainId}/rpc"
  • privateKey (String): The private key of the account to use for signing transactions.

Transaction Parameters

  • to (String): The recipient address of the transaction.

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

  • data (String): The data payload for the transaction.

Example Code Snippets

Initializing the SDK

const config = {
  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"
};

const gassless = initialize(config);
console.log("0xGassless SDK initialized.");

Sending a Transaction

const transaction = {
  to: "0xRecipientAddress",
  value: "0",
  data: "0xYourData"
};

gassless.sendTransaction(transaction)
  .then(response => console.log("Transaction sent:", response))
  .catch(error => console.error("Transaction failed:", error));

Checking Transaction Status

const transactionHash = "0xYourTransactionHash";

gassless.getTransactionStatus(transactionHash)
  .then(status => console.log("Transaction status:", status))
  .catch(error => console.error("Failed to retrieve status:", error));

Fetching Account Balance

const address = "0xYourAccountAddress";

gassless.getBalance(address)
  .then(balance => console.log("Account balance:", balance))
  .catch(error => console.error("Failed to retrieve balance:", error));

Additional Resources

For more detailed examples and advanced usage, refer to the 0xGassless SDK documentation.