Skip to content

Quickstart

Get a user logged in, their wallet connected, and a gasless transaction sent — all in under five minutes.

Terminal window
npm install 0xgas-auth

If you’re using a framework like Next.js or Vite, this is all you need. The package ships both ESM and CommonJS builds.

Head to the 0xGasless Dashboard and create a project. Copy the API key — you’ll need it in the next step.

import { OxGasClient } from '0xgas-auth';
const client = new OxGasClient({
apiKey: 'your-api-key',
chainId: 11155111, // Sepolia testnet
bundlerUrl: 'https://bundler.0xgasless.com/11155111',
paymasterUrl: 'https://paymaster.0xgasless.com/v1/11155111/rpc/your-api-key',
});

OxGasClient combines authentication and smart account management into one object. You can always use OxGasAuth alone if you only need signing.

const wallet = await client.login();
console.log('EOA address:', wallet.address);
console.log('Email:', wallet.email);

This opens the widget — an iframe overlay where the user enters their email and password. Once they authenticate, the widget closes and login() resolves with their wallet information.

If the user is already logged in from a previous session, login() returns immediately without opening the widget.

const smartAccountAddress = await client.setupSmartAccount();
console.log('Smart account:', smartAccountAddress);

The smart account address is deterministic — calling setupSmartAccount() again returns the same address. You only need to call it once per session.

const { userOpHash } = await client.sendTransaction({
to: '0xRecipientAddress',
value: 0n,
data: '0x',
});
console.log('UserOperation hash:', userOpHash);

The transaction is submitted through the 0xGasless bundler and sponsored by the paymaster. The user pays no gas.

import { OxGasClient } from '0xgas-auth';
const client = new OxGasClient({
apiKey: 'your-api-key',
chainId: 11155111,
bundlerUrl: 'https://bundler.0xgasless.com/11155111',
paymasterUrl: 'https://paymaster.0xgasless.com/v1/11155111/rpc/your-api-key',
});
async function main() {
// Authenticate
const wallet = await client.login();
console.log('Connected:', wallet.address);
// Set up smart account
const smartAccount = await client.setupSmartAccount();
console.log('Smart account:', smartAccount);
// Send a transaction
const response = await client.sendTransaction({
to: '0x000000000000000000000000000000000000dEaD',
value: 0n,
data: '0x',
});
console.log('Transaction submitted:', response.userOpHash);
}
main();