Quickstart
Get a user logged in, their wallet connected, and a gasless transaction sent — all in under five minutes.
1. Install the package
Section titled “1. Install the package”npm install 0xgas-authIf you’re using a framework like Next.js or Vite, this is all you need. The package ships both ESM and CommonJS builds.
2. Get an API key
Section titled “2. Get an API key”Head to the 0xGasless Dashboard and create a project. Copy the API key — you’ll need it in the next step.
3. Initialize the client
Section titled “3. Initialize the client”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.
4. Log the user in
Section titled “4. Log the user in”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.
5. Create a smart account
Section titled “5. Create a smart account”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.
6. Send a gasless transaction
Section titled “6. Send a gasless transaction”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.
Complete example
Section titled “Complete example”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();What’s next
Section titled “What’s next”- Configuration — full list of options
- Authentication overview — understand what happens during login
- Smart Account Integration — go deeper on gasless transactions