Skip to main content

Overview

Users can pay gas fees directly with native tokens from their smart accounts. This provides a familiar payment method while still benefiting from the enhanced features of smart wallets.

Implementations

Gelato Gasless SDK

npm install @gelatocloud/gasless viem

Example: Gelato Smart Account

1

Import Dependencies

import { createGelatoBundlerClient, toGelatoSmartAccount, token } from '@gelatocloud/gasless';
import { baseSepolia } from "viem/chains";
import { createPublicClient, http } from 'viem';
import { privateKeyToAccount } from "viem/accounts";
2

Create Gelato Smart Account

const owner = privateKeyToAccount(process.env.PRIVATE_KEY);

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

const account = await toGelatoSmartAccount({
  client,
  owner,
});
3

Create Gelato Bundler Client

const tokenAddress = "0x0000000000000000000000000000000000000000"; // Native

const bundler = await createGelatoBundlerClient({
  account,
  apiKey: process.env.GELATO_API_KEY,
  client,
  payment: token(tokenAddress),
  pollingInterval: 100
});
4

Send User Operation

const hash = await bundler.sendUserOperation({
  calls: [
    {
      data: '0xd09de08a',
      to: '0xE27C1359cf02B49acC6474311Bd79d1f10b1f8De'
    }
  ]
});
console.log(`User operation hash: ${hash}`);

const { receipt } = await bundler.waitForUserOperationReceipt({ hash });
console.log(`Transaction hash: ${receipt.transactionHash}`);

Additional Resources