Gelato Network
Search
⌃K

Gasless Wallet

Overview

Gasless Wallet allows externally owned accounts (EOAs) to deploy their own smart contract wallet whilst ensuring the same address across EVM networks by using the CREATE2 opcode. This means that you can predict the contract address pre-deployment. Our Gasless Wallet SDK under the hood utilises one of the most secure and widespread smart contract wallets, Safe. This approach gives developers the flexibility to have their users' transactions relayed and sponsored with 1Balance without needing to update their existing contracts.

Installation

yarn add @gelatonetwork/gasless-wallet
or
npm install @gelatonetwork/gasless-wallet

Class

class GaslessWallet
constructor(eoaProvider: EoaProvider, config: GaslessWalletConfig);

Arguments

type EoaProvider =
| ethers.providers.ExternalProvider
| ethers.providers.JsonRpcFetchFunc;
type GaslessWalletConfig = {
apiKey: string;
}
  • apiKey: an API key used to authenticate your sponsorship

Methods

init

init(): Promise<void>;
The init function should be invoked before using other methods as it sets up the instance for further processing.

getAddress

getAddress(): string;
This function returns the address of the gasless wallet, regardless of whether the wallet on the chain has already been deployed or not.

sendTransaction

sendTransaction(to: string, data: string, value?: BigNumberish): Promise<RelayResponse>;
This function relays the transaction data to the target address via the EOA's Safe Proxy, their gasless wallet. Therefore, the msg.sender is this gasless wallet. This transaction is sponsored via a 1Balance api key which is passed into the constructor of the GaslessWallet class.

Arguments

  • to: The target address
  • data: The transaction data
  • value: Optional value for payable

isInitialized

isInitialized(): boolean;
This function returns whether the init function is already invoked or not.

isDeployed

isDeployed(): Promise<boolean>;
This function returns whether the gasless wallet has already been deployed.