Gelato Network
Search…
⌃K

Gasless Onboarding

Overview

Gasless Onboarding is a combination of Gasless Wallet and Web3Auth which gives developers the ability to onboard their users via social logins such as Google, Facebook, Discord, etc.

Installation

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

Class

class GaslessOnboarding
constructor(loginConfig: LoginConfig, gaslessWalletConfig: GaslessWalletConfig);

Arguments

interface LoginConfig {
chain: { id: number; rpcUrl: string };
ui?: {
theme?: "light" | "dark";
};
openLogin?: {
mfa?: LoginSettings["mfaLevel"];
redirectUrl?: string;
};
}
chain
  • id: The Chain ID of the network
  • rpcUrl: The RPC provider URL
ui
  • theme: light or dark
openLogin
  • mfa: The multi-factor authentication configuration for openLogin. Possible values are:
    • optional: Setting mfaLevelto optional will present the MFA screen to the user on every login but they will have the option to skip it.
    • default: Setting the mfaLevel to default will present the MFA screen to user on every third login.
    • mandatory: Setting mfaLevel to mandatory will make it mandatory for user to setup MFA after login.
    • none: Setting mfaLevel to none will skip the mfa setup screen totally.
  • redirectUrl: The url to which the user will be redirected after the Web3Auth login flow
type GaslessWalletConfig = {
apiKey: string;
}
  • apiKey: a 1Balance 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.

getGaslessWallet

getGaslessWallet(): GaslessWallet;
The function returns an instance of the Gasless Wallet.

getProvider

getProvider(): SafeEventEmitterProvider | null;
The returned instance contains the respective provider corresponding to your selected blockchain. You can use this provider to connect your user to the blockchain and make transactions.

getUserInfo

getUserInfo(): Promise<Partial<UserInfo>>;
If the user is logged in with social media accounts, this function can be used to fetch user related data such as email, name, profileImage etc.

login

login(): Promise<SafeEventEmitterProvider>;
This function pops up the login modal on UI, and returns the provider instance after a successful login.

logout

logout(): Promise<void>;
This function logs the user out and clears the cache.