Use the @abstraxn/agent-kit npm package from your backend only. It wraps Agent Kit REST and Abstraxn server wallet provisioning so each agent gets an EVM (and optionally Solana) address plus a one-time access key for signing. For bring-your-own-wallet (MetaMask, viem, no accessKey), see External wallet.

Prerequisites

Install

npm install @abstraxn/agent-kit

Initialize the client

import { AgentKitClient } from '@abstraxn/agent-kit';

const agentKit = new AgentKitClient({
  apiKey: process.env.ABSTRAXN_API_KEY!, // same key as dashboard Overview
  baseUrl: process.env.AGENT_KIT_BASE_URL, // optional; default production host
});
Env variableExamplePurpose
ABSTRAXN_API_KEYFrom dashboard OverviewApplication-scoped key
AGENT_KIT_BASE_URLhttps://dev-agent-kit.abstraxn.comOverride for dev/staging

Create an agent (primary flow)

createAgent() is the flow used in the sample backend API (NestJS). It:
  1. Registers the agent in Agent Kit (POST /agents under the hood).
  2. Provisions an Abstraxn server wallet (P-256 access key + organization).
  3. Returns wallet.accessKey — required for all future signing and autonomous actions.
const { agent, wallet } = await agentKit.createAgent({
  name: 'Trading Assistant',
  description: 'Executes trades within spend policy',
  userIdentity: '[email protected]', // your stable user id
  userEmail: '[email protected]',       // optional
  metadata: { tier: 'pro' },             // optional
});

// Agent Kit record
console.log(agent.id);        // UUID — use in MCP agent_id when needed
console.log(agent.apiKey);    // per-agent MCP/REST key (optional second credential)

// Wallet — persist on YOUR backend
console.log(wallet.evmAddress);
console.log(wallet.solanaAddress);   // when enabled
console.log(wallet.organizationId);
console.log(wallet.accessKey);       // ⚠️ shown once — encrypt at rest

What to store in your database

FieldSecret?Used for
agent.idNoAgent Kit id, MCP agent_id, identity APIs
agent.apiKeyYesPer-agent MCP auth (alternative to app key + agent_id)
wallet.accessKeyCriticalServer wallet auth — signing, x402, transfers
wallet.evmAddressNoDisplay, balance, transfers
wallet.organizationIdNoServer signer RPC client scope
userIdentityNoMust match authenticate() calls
accessKey cannot be retrieved again. If you lose it, create a new agent or implement a key-rotation flow with your Abstraxn contact. Encrypt the column (see ENCRYPTION_KEY in the sample app).

Reference: how the sample backend persists secrets

import { encrypt } from './common/crypto.helper';

const accessKeyEncrypted = encrypt(wallet.accessKey, process.env.ENCRYPTION_KEY!);

await agentsRepo.save({
  userId,
  agentId: kitAgent.id,
  apiKey: kitAgent.apiKey,
  evmAddress: wallet.evmAddress,
  organizationId: wallet.organizationId,
  userIdentity: kitAgent.userIdentity ?? userId,
  accessKey: accessKeyEncrypted, // never return in API responses
});

Sign and send transactions (autonomous actions)

After onboarding, load the decrypted accessKey and use getServerSigner():
const signer = agentKit.getServerSigner();

await signer.authenticate({
  userIdentity: storedUserIdentity,
  accessKey: decryptedAccessKey,
});

const client = signer.createPublicClient({
  rpcUrl: process.env.RPC_URL!,
  chainId: 80002,
  organizationId: storedOrganizationId,
  fromAddress: storedEvmAddress as `0x${string}`,
});

const prepared = await client.prepareTransaction({
  to: '0xRecipient...' as `0x${string}`,
  value: 1_000_000_000_000_000n,
});

const txHash = await client.signAndSendPreparedTransaction(
  prepared.unsignedTransaction,
);
Your backend uses this path when:

Other SDK methods

MethodWhen to use
listAgents / getAgentAdmin dashboards, sync with your DB
updateAgent / deleteAgentLifecycle management
updateSpendPolicyCap paid MCP tool spend per agent
registerAgentIdentityERC-8004 on-chain identity — supported chainId: 1, 11155111, 137, 80002, 8453, 84532, 56, 97, 42161, 43114 (details)
createAgentDirectAgent row only, no auto-wallet (advanced)
bindAgentAttach existing EVM/Solana addresses

MCP from your backend

Point MCP at the same URL as the dashboard MCP URL:
export MCP_SERVER_URL="https://agent-kit.abstraxn.com/mcp"
export MCP_SERVER_AUTH_TOKEN="$ABSTRAXN_API_KEY"
When using the application API key, pass agent_id in tool arguments for multi-agent apps:
{
  "name": "get_balance",
  "arguments": {
    "agent_id": "<agent.id from createAgent>",
    "chain": "ethereum"
  }
}
Or use each agent’s agent.apiKey as the MCP Authorization value (no agent_id required).

Security checklist

  • Store ABSTRAXN_API_KEY and all accessKey values only on the server.
  • Encrypt accessKey at rest; never log it.
  • Do not pass accessKey to the browser or mobile clients.
  • Use per-user auth (JWT) in your API; map users to agent rows in your DB.

Next steps