Skip to content

gelatodigital/smartwallet

Repository files navigation

Gelato SmartWallet SDK

A Modern Account Abstraction SDK for building and interacting with smart wallets.

Note

This library is currently in Developer Preview. It may include breaking changes in non-major versions.

Prerequisites

  • Node.js >= 23
  • pnpm >= 10.8.1
  • Gelato API Key for sponsored transactions via 1Balance (Get your key here

Packages

Overview

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

const privateKey = generatePrivateKey();
const account = privateKeyToAccount(privateKey);

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

const swc = await createGelatoSmartWalletClient(client, { apiKey });

const response = await swc.execute({
    payment: sponsored(),
    calls: [
      {
        to: "0xEEeBe2F778AA186e88dCf2FEb8f8231565769C27",
        data: "0xd09de08a",
        value: 0n
      }
    ]
});

response.on("submitted", (status) => {
    console.log(`Transaction submitted: ${status.transactionHash}`);
});

response.on("success", async (status) => {
    console.log(`Transaction successful: ${status.transactionHash}`);
});

response.on("error", (error) => {
    console.error(`Transaction failed: ${error.message}`);
});

Quick Start

NPM

  1. Install package
pnpm i @gelatonetwork/smartwallet

Locally

  1. Clone the repository:
git clone --recurse-submodules https://github.com/gelatodigital/smartwallet.git
cd smartwallet
  1. Install dependencies:
pnpm install
  1. Build the project:
pnpm build

Running Examples

The project includes several examples in the examples directory. To run an example:

  1. Navigate to the example directory:
cd examples/erc20  # or any other example directory
  1. Install dependencies:
pnpm install
  1. Run the example:
pnpm dev

Project Structure

  • src/ - Gelato SmartWallet SDK
  • plugins/ - Plugins built on top of Gelato SmartWallet SDK
  • examples/ - Example implementations

Development

  • Format code:
pnpm format
  • Lint code:
pnpm lint
  • Run tests:
pnpm test

Contributing

  1. Create a changeset for your changes:
pnpm changeset
  1. Build and test your changes:
pnpm build
pnpm test
  1. Submit a pull request

License

This project is licensed under the terms of the MIT license.

About

Gelato SmartWallet SDK for Account Abstraction

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 6