Catalog npm
PACKAGE EXPLORERView in registry

@0xgasless/agent-sdk

npm

Universal Agent SDK combining ERC-8004 identity/reputation with x402 gasless payments across chains

agentserc8004evmgaslesssdkx402
Versions collected2
Direct dependencies13From release 0.1.2
Last observed21 Oct, 08:55 UTC

README

Current package documentation

@0xgasless/agent-sdk

Version License Node

The Financial Layer for Autonomous AI Agents

ERC-8004 Identity + x402 Gasless Payments + MoltPay CLI

Quick Start • MoltPay CLI • SDK Reference • Examples


🎯 What is this?

A wallet-agnostic SDK for building autonomous AI agents on Avalanche with:

  • 🆔 ERC-8004 - On-chain agent identity, reputation, and validation
  • 💸 x402 Payments - Gasless payments via 0xGasless facilitator
  • 🦞 MoltPay CLI - Interactive command-line for agent registration & payments
  • 🤖 LangChain Tools - Pre-built tools for AI agent frameworks
  • 🔗 Fetch.ai Integration - Optional ASI-1 agent integration

📦 Installation

NPM Package

npm install @0xgasless/agent-sdk ethers

Global CLI (MoltPay)

# Install globally for CLI access
npm install -g @0xgasless/agent-sdk

# Or use npx without installing
npx @0xgasless/agent-sdk moltpay --help

🚀 Quick Start

Step 1: Install Dependencies

npm install @0xgasless/agent-sdk ethers dotenv

Step 2: Create Environment File

# .env
PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
RPC_URL=https://api.avax-test.network/ext/bc/C/rpc

Step 3: Initialize SDK

import { AgentSDK, fujiConfig } from '@0xgasless/agent-sdk';
import { Wallet, JsonRpcProvider } from 'ethers';
import 'dotenv/config';

// Create wallet from private key
const provider = new JsonRpcProvider(process.env.RPC_URL);
const wallet = new Wallet(process.env.PRIVATE_KEY!, provider);

// Initialize SDK
const sdk = new AgentSDK({
  networks: fujiConfig.networks,
  defaultNetwork: 'fuji',
  signer: wallet,
});

// Register agent on ERC-8004
const agentId = await sdk.erc8004.identity().register('ipfs://QmAgentMetadata...');
console.log('Agent registered with ID:', agentId);

🦞 MoltPay CLI

MoltPay is the interactive CLI for managing agent wallets, registrations, and payments.

Installation

# Global install (recommended)
npm install -g @0xgasless/agent-sdk

# Verify installation
moltpay --help

Commands

CommandDescription
moltpay initInitialize agent wallet and environment
moltpay registerRegister agent identity on ERC-8004
moltpay paySend crypto payments
moltpay verifyVerify agent on MoltBook social graph

Step-by-Step Setup

1. Initialize Your Agent

moltpay init

Follow the interactive prompts:

  • Select network: Avalanche Fuji (Testnet) or Avalanche Mainnet
  • Enter private key or generate new wallet

This creates a .env file with your configuration.

2. Register on ERC-8004

moltpay register

This will:

  • Check if you already have an identity
  • Prompt for agent name and service domain
  • Mint your ERC-8004 identity NFT on-chain

3. Make Payments

# Interactive mode
moltpay pay

# Direct mode
moltpay pay 10 USDC 0xRecipientAddress

4. Verify on MoltBook (Optional)

moltpay verify

Links your on-chain identity to your social presence.

Hosted CLI (Coming Soon)

# 🚧 COMING SOON - Hosted version with managed wallets
# npx @0xgasless/moltpay-hosted login
# npx @0xgasless/moltpay-hosted dashboard

📍 Deployed Contracts

Avalanche C-Chain Mainnet (Chain ID: 43114) ✅ LIVE

ERC-8004 Registries

x402 Gasless Payments

ComponentValue
Facilitator URLhttps://x402.0xgasless.com
Relayer Contract0x457Db7ceBAdaF6A043AcE833de95C46E982cEdC8
EIP-712 Domain{ name: "A402", version: "1", chainId: 43114 }

Supported Payment Tokens


Avalanche Fuji Testnet (Chain ID: 43113)

ERC-8004 Registries

x402 Gasless Payments (Testnet)

ComponentValue
Facilitator URLhttps://testnet.0xgasless.com
Relayer Contract0x8BD697733c31293Be2327026d01aE393Ab2675C4

📖 SDK Reference

Core SDK

import { AgentSDK, fujiConfig } from '@0xgasless/agent-sdk';

const sdk = new AgentSDK({
  networks: fujiConfig.networks,
  defaultNetwork: 'fuji',
  signer: wallet, // Any ethers.Signer
});

// Get wallet address
const address = await sdk.getAddress();

// Access ERC-8004 clients
const identity = sdk.erc8004.identity();
const reputation = sdk.erc8004.reputation();
const validation = sdk.erc8004.validation();

// Access x402 facilitator
const facilitator = sdk.getFacilitator();

ERC-8004 Identity

import { IdentityV2 } from '@0xgasless/agent-sdk';

// Register new agent
const agentId = await identity.register('ipfs://metadata-uri');

// Get agent by owner
const agentId = await identity.getAgentIdByOwner('0xOwnerAddress');

// Get agent metadata URI
const uri = await identity.tokenURI(agentId);

// Check balance
const count = await identity.balanceOf('0xAddress');

ERC-8004 Reputation

import { ReputationV2 } from '@0xgasless/agent-sdk';

// Get reputation score
const score = await reputation.getScore(agentId);

// Get reputation history
const history = await reputation.getHistory(agentId);

x402 Payments

import { FacilitatorClient, x402Fetch } from '@0xgasless/agent-sdk';

// Create payment payload
const payload = await sdk.x402.createPaymentPayload({
  to: '0xRecipient',
  amount: '5000000', // 5 USDT (6 decimals)
  token: '0xUSDTAddress',
});

// Use x402 fetch for gasless requests
const response = await x402Fetch('https://api.example.com/paid-endpoint', {
  method: 'POST',
  headers: { 'X-402-Payment': JSON.stringify(payload) },
});

LangChain Tools

import { getAgentTools, registerAgentTool, getBalanceTool } from '@0xgasless/agent-sdk';

// Get all pre-built tools
const tools = getAgentTools(sdk);

// Or use individual tools
const registerTool = registerAgentTool(sdk);
const balanceTool = getBalanceTool(sdk);

// Use with LangChain agent
const agent = new ChatOpenAI({ ... });
const chain = AgentExecutor.fromAgentAndTools({
  agent,
  tools,
});

Session Keys (For Autonomous Agents)

import { SessionKeyHelper } from '@0xgasless/agent-sdk';
import { parseUnits } from 'ethers';

// Generate session key with constraints
const sessionKey = SessionKeyHelper.generateSessionKey({
  maxSpendPerTx: parseUnits('10', 6),      // 10 USDT per tx
  maxSpendPerDay: parseUnits('100', 6),    // 100 USDT per day
  validForSeconds: 7 * 24 * 60 * 60,       // 7 days
  whitelistedContracts: ['0x...'],
});

// Create wallet from session key
const sessionWallet = SessionKeyHelper.createWallet(sessionKey, provider);

// Validate before spending
const validation = SessionKeyHelper.validateTransaction(
  sessionKey,
  { to: '0x...', value: parseUnits('5', 6) },
  spentToday
);

if (!validation.valid) {
  console.error('Transaction blocked:', validation.reason);
}

Fetch.ai Integration

import { FetchAIAgent } from '@0xgasless/agent-sdk';

const fetchAgent = new FetchAIAgent(sdk, {
  apiKey: process.env.FETCHAI_API_KEY,
  model: 'asi1-mini',
});

const result = await fetchAgent.query('Research DeFi trends on Avalanche');
console.log(result);

🔧 Configuration

Environment Variables

VariableRequiredDescription
PRIVATE_KEYYesAgent wallet private key
RPC_URLNoRPC endpoint (defaults to Fuji)
MOLTPAY_NETWORKNoNetwork override (avax-fuji or avax-mainnet)
X402_FACILITATOR_URLNoCustom facilitator URL

Network Configuration

import { 
  fujiConfig, 
  mainnetConfig, 
  ERC8004_V2, 
  ERC8004_V2_MAINNET 
} from '@0xgasless/agent-sdk';

// Testnet (Fuji)
const testnetSdk = new AgentSDK({
  networks: fujiConfig.networks,
  defaultNetwork: 'fuji',
  signer: wallet,
});

// Mainnet
const mainnetSdk = new AgentSDK({
  networks: mainnetConfig.networks,
  defaultNetwork: 'mainnet',
  signer: wallet,
});

// Contract addresses
console.log(ERC8004_V2);          // Fuji addresses
console.log(ERC8004_V2_MAINNET);  // Mainnet addresses

📁 Examples

Basic Agent Registration

import { ERC8004Provider } from '@0xgasless/agent-sdk';

const provider = new ERC8004Provider(
  'https://api.avax-test.network/ext/bc/C/rpc',
  process.env.PRIVATE_KEY!,
  'avax-fuji'
);

// Check registration status
const isRegistered = await provider.isRegistered();

if (!isRegistered) {
  const agentId = await provider.register('https://myagent.com/metadata.json');
  console.log('Registered with ID:', agentId);
}

With Privy Wallet

import { usePrivy, useWallets } from '@privy-io/react-auth';
import { AgentSDK, fujiConfig } from '@0xgasless/agent-sdk';

function AgentComponent() {
  const { ready, authenticated } = usePrivy();
  const { wallets } = useWallets();

  const initSDK = async () => {
    const wallet = wallets[0];
    const provider = await wallet.getEthersProvider();
    const signer = await provider.getSigner();

    const sdk = new AgentSDK({
      ...fujiConfig,
      signer,
    });

    return sdk;
  };
}

With MetaMask

import { BrowserProvider } from 'ethers';
import { AgentSDK, fujiConfig } from '@0xgasless/agent-sdk';

async function connectMetaMask() {
  const provider = new BrowserProvider(window.ethereum);
  await provider.send('eth_requestAccounts', []);
  const signer = await provider.getSigner();

  const sdk = new AgentSDK({
    ...fujiConfig,
    signer,
  });

  return sdk;
}

🔑 Wallet Support

This SDK is completely wallet-agnostic. Use any wallet:

WalletStatusExample
ethers.js Wallet✅ Supportednew Wallet(privateKey, provider)
Session Keys✅ SupportedSessionKeyHelper.createWallet(...)
Privy✅ Supportedwallet.getEthersProvider()
Dynamic.xyz✅ SupportedprimaryWallet.getWalletClient()
MetaMask✅ SupportedBrowserProvider(window.ethereum)
Safe✅ SupportedSafeWalletProvider

🛠️ Development

Building from Source

git clone https://github.com/0xgasless/agent-sdk.git
cd agent-sdk

npm install
npm run build
npm run build:cli

Running Tests

npm test

Local CLI Development

# Build and link locally
npm run build:cli
node dist/cli/index.js --help

📄 License

MIT - see LICENSE


🤝 Support


Built with ❤️ by 0xGasless

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 2

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.2Registry latest16 Feb 202613
0.1.18 Feb 202613

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 08:55 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:7797cea5ebca4cade88e1fc79cf8d04e83f7c773ba9b0a2d879703f57b40489e