Catalog npm
Back to packageRELEASE DETAILS

0.1.1

npm

@0xgasless/agent-sdk

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

agentserc8004evmgaslesssdkx402
Published8 Feb 2026
Direct dependencies13
Transitive dependenciesNot calculated

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.

Declared dependencies 14

Native requirements
13 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
ora
Environment
{
  "local_name": "ora",
  "alias": false,
  "peer_metadata": null
}
^9.1.0runtime
axios
Environment
{
  "local_name": "axios",
  "alias": false,
  "peer_metadata": null
}
^1.7.7runtime
chalk
Environment
{
  "local_name": "chalk",
  "alias": false,
  "peer_metadata": null
}
^5.6.2runtime
dotenv
Environment
{
  "local_name": "dotenv",
  "alias": false,
  "peer_metadata": null
}
^17.2.3runtime
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
^6.0.0runtime
inquirer
Environment
{
  "local_name": "inquirer",
  "alias": false,
  "peer_metadata": null
}
^13.2.2runtime
commander
Environment
{
  "local_name": "commander",
  "alias": false,
  "peer_metadata": null
}
^14.0.3runtime
@langchain/core
Environment
{
  "local_name": "@langchain/core",
  "alias": false,
  "peer_metadata": null
}
^1.1.18runtime
@langchain/langgraph
Environment
{
  "local_name": "@langchain/langgraph",
  "alias": false,
  "peer_metadata": null
}
^1.1.2runtime
@privy-io/server-auth
Environment
{
  "local_name": "@privy-io/server-auth",
  "alias": false,
  "peer_metadata": null
}
^1.32.5runtime
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.5.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^20development
ethers
Environment
{
  "local_name": "ethers",
  "alias": false,
  "peer_metadata": null
}
^6.0.0peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "23e253da3a61929fd1804c8ba5238b1f882faa89",
  "tarball": "https://registry.npmjs.org/@0xgasless/agent-sdk/-/agent-sdk-0.1.1.tgz",
  "fileCount": 129,
  "integrity": "sha512-+mb+CM548mlBlVaWmveCpR8UuUSdzcsdJJ8UKw5WKT6ar912fAXIg3D/iFZc1KjvmlyyQe6SZmYDXCcm0Ckuhg==",
  "signatures": [
    {
      "sig": "MEUCIGxJuPeFBpxWXzB8RKWzpfSjR2OwlIt2hO3qqnWwfuy9AiEAoFpzzdynu3wrvW0rj8qlQGw3VYlHphFeIjvRNg+GW6w=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 385180
}

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_version:7370ca7b68e20831f19d39a35993a052d2a67f7aa11ae7f94841df06dc163d76

Other collected versions

0.1.216 FebView all collected versions →