Getting Started

Getting Started

This guide will help you get up and running with WalletPilot in under 5 minutes.

Prerequisites

Installation

npm install walletpilot-sdk

Or with yarn:

yarn add walletpilot-sdk

Initialize the SDK

import { WalletPilot } from 'walletpilot-sdk';
 
const pilot = new WalletPilot({ 
  apiKey: 'wp_your_api_key',
  // Optional: custom RPC URLs
  rpcUrls: {
    1: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
    137: 'https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY',
  }
});

Request Permission

Before executing transactions, you need to request permission from the user:

const permission = await pilot.requestPermission({
  // Spending limits per token
  spend: { 
    ETH: '0.1',      // Max 0.1 ETH total
    USDC: '100'      // Max 100 USDC total
  },
  
  // Allowed contracts/protocols
  contracts: ['uniswap', 'aave'],
  
  // Allowed chains
  chains: [1, 137],  // Ethereum + Polygon
  
  // Permission expiry
  expiry: '7d'       // Valid for 7 days
});
 
console.log('Permission ID:', permission.id);
console.log('Deep link:', permission.deepLink);

The user will be prompted to approve this permission via MetaMask.

Execute a Transaction

Once you have permission, execute transactions:

const tx = await pilot.execute({
  permissionId: permission.id,
  to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
  value: '0.01',
  data: '0x...', // Transaction calldata
  chainId: 1
});
 
console.log('Transaction hash:', tx.hash);
console.log('Status:', tx.status);

Check Permission Usage

const usage = await pilot.getPermissionUsage(permission.id);
 
console.log('ETH spent:', usage.spent.ETH);
console.log('Transactions:', usage.txCount);
console.log('Remaining ETH:', usage.remaining.ETH);

Revoke Permission

Users or developers can revoke permissions at any time:

await pilot.revokePermission(permission.id);

Next Steps