Gelato Logo

Gelato

Smart Account Dev Demo

Experience the power of Gelato Smart Wallet with different account types and transaction methods. Create accounts, view balances, and execute gasless transactions with ease.

Account Creation

Create Gelato, Kernel, or Safe smart accounts

Gas Sponsorship

Execute gasless transactions with Gelato paymaster

ERC20 Gas Payments

Execute transactions with ERC20 tokens

Gas Estimations

Estimate gas for transactions

Installation

Package Installation

npm install @gelatonetwork/smartwallet-react-sdk

Smart Account Creation

Implementation Code

import { createGelatoSmartWalletClient } from "@gelatonetwork/smartwallet";
import { http, type Hex, createWalletClient, createPublicClient } from "viem";
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
import { gelato } from "@gelatonetwork/smartwallet/accounts";
import { baseSepolia } from "viem/chains";

const privateKey = (process.env.PRIVATE_KEY ?? generatePrivateKey()) as Hex;
const owner = privateKeyToAccount(privateKey);

const publicClient = createPublicClient({
  chain: baseSepolia,
  transport: http(),
});

const account = await gelato({
  owner,
  client: publicClient,
});

const client = createWalletClient({
  account,
  chain: baseSepolia,
  transport: http(),
});

const smartWalletClient = await createGelatoSmartWalletClient(client);

Create Account

or

Transaction Types

1. Sponsored Transactions

Implementation Code

import { type GelatoSmartWalletClient, sponsored } from "@gelatonetwork/smartwallet";

export async function sponsoredTxn(
  smartWalletClient: GelatoSmartWalletClient
) {
  console.log("Executing transaction...");

  const response = await smartWalletClient.execute({
    payment: sponsored(sponsorApiKey),
    calls: [
      {
        to: zeroAddress,
        data: "0x",
        value: BigInt(0),
      },
    ],
  });

  console.log(`Your Gelato id is: ${response.id}`);
  console.log(
    `Check the status of your request here: https://api.gelato.digital/tasks/status/${response.id}`
  );

  const txHash = await response.wait();
  return { userOpHash: response.id, txHash };
}

Execute Transaction

Create Account First

You need to create a smart account before executing sponsored transactions.

2. ERC20 Gas Transactions

Implementation Code

import { type GelatoSmartWalletClient, erc20 } from "@gelatonetwork/smartwallet";

export async function erc20GasTxn(
  smartWalletClient: GelatoSmartWalletClient,
  tokenAddress: `0x${string}`
) {
  console.log("Executing transaction...");

  const response = await smartWalletClient.execute({
    payment: erc20(tokenAddress),
    calls: [
      {
        to: zeroAddress,
        data: "0x",
        value: BigInt(0),
      },
    ],
  });

  console.log(`Your Gelato id is: ${response.id}`);
  console.log(
    `Check the status of your request here: https://api.gelato.digital/tasks/status/${response.id}`
  );

  const txHash = await response.wait();
  return { userOpHash: response.id, txHash };
}

Execute Transaction

Create Account First

You need to create a smart account before executing ERC20 transactions.

Selected: USD Coin (0x036CbD53842c5426634e7929541eC2318f3dCF7e)

3. Native Gas Transactions

Implementation Code

import { type GelatoSmartWalletClient, native } from "@gelatonetwork/smartwallet";

export async function nativeGasTxn(
  smartWalletClient: GelatoSmartWalletClient
) {
  console.log("Executing transaction...");

  const response = await smartWalletClient.execute({
    payment: native(),
    calls: [
      {
        to: zeroAddress,
        data: "0x",
        value: BigInt(0),
      },
    ],
  });

  console.log(`Your Gelato id is: ${response.id}`);
  console.log(
    `Check the status of your request here: https://api.gelato.digital/tasks/status/${response.id}`
  );

  const txHash = await response.wait();
  return { userOpHash: response.id, txHash };
}

Execute Transaction

Create Account First

You need to create a smart account before executing native transactions.

Gas Estimation

Implementation Code

import { type GelatoSmartWalletClient, native, sponsored, erc20 } from "@gelatonetwork/smartwallet";
import { type Call } from "viem";

export async function estimateGas(
  smartWalletClient: GelatoSmartWalletClient,
  method: string,
  tokenAddress?: `0x${string}`,
  calls?: Call[]
) {
  
    const gasResults = await smartWalletClient.estimate({
      payment: method === "native" ? native() : method === "erc20" ? erc20(tokenAddress) : sponsored(sponsorApiKey),
      calls: calls ?? [],
    });

  return gasResults;
}

Estimate Gas

Create Account First

You need to create a smart account before estimating gas.

Call #1
Gelato Logo
Gelato Smart Wallet Dev Demo

© 2025 Gelato Network. Smart wallet demo for educational purposes.