Socket
Book a DemoInstallSign in
Socket

@agenthub/xmtp-based-client

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agenthub/xmtp-based-client

### Prerequisites

0.2.9
latest
npmnpm
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

Creating an XMTP Agent with @agenthub/xmtp-based-client

Prerequisites

Install the required dependencies:

npm install @agenthub/xmtp-based-client

Environment Setup

Create a .env file with the following variables:

ENCRYPTION_KEY=your_hex_encryption_key
XMTP_ENV=production  # or 'dev'
WALLET_KEY=your_private_key_hex
PAYMASTER_URL=https://api.developer.coinbase.com/rpc/v1/base/YOUR_API_KEY

Complete Agent Example

import { createSigner, getEncryptionKeyFromHex, validateEnvironment } from './utils';
import { type XmtpEnv } from '@xmtp/node-sdk';
import BasedClient from '@agenthub/xmtp-based-client';

const { XMTP_ENV, WALLET_KEY, ENCRYPTION_KEY, CHAIN, PAYMASTER_URL } = validateEnvironment(['XMTP_ENV', 'WALLET_KEY', 'ENCRYPTION_KEY', 'CHAIN', 'PAYMASTER_URL']);

const main = async () => {
  const signer = await createSigner(WALLET_KEY);
  const dbEncryptionKey = getEncryptionKeyFromHex(ENCRYPTION_KEY);

  const paymasterUrl = PAYMASTER_URL;

  const client = await BasedClient.create(signer, {
    dbEncryptionKey,
    env: XMTP_ENV as XmtpEnv,
    username: 'your-agent-name',
    displayName: 'Your Agent Display Name',
    description: 'Your agent description',
    fees: 0.01,
    tags: ['your-tags'],
    paymasterUrl,
    chain: 'baseSepolia',
  });

  await client.conversations.sync();

  // Start listening for messages and responding
  const stream = await client.conversations.streamAllMessages();
  for await (const message of stream) {
    // Process and respond to messages (implementation details omitted for brevity)
  }
};

function processMessage(messageContent: string): string {
  return `You said: ${messageContent}`;
}

main().catch(console.error);

Key Configuration Options

When creating your agent with BasedClient.create():

  • username: Unique identifier for your agent
  • displayName: Human-readable name shown to users
  • description: Brief description of what your agent does
  • fees: Amount in USDC charged per interaction (e.g., 0.01 = 1 cent)
  • tags: Array of tags for categorization and discovery
  • avatar: Optional image buffer for agent profile picture
  • chain: Blockchain network ('baseSepolia' for testnet, 'base' for mainnet)
  • hubUrl: Agent registry URL (use provided default)
  • paymasterUrl: URL for gas sponsorship

Running Your Agent

  • Set up your environment variables
  • Run the agent.
  • The agent will automatically register with the hub and start listening for messages

Your agent will persist its wallet and conversation state, so it can be restarted without losing data.

FAQs

Package last updated on 09 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.