Node.js SDK

Node.js SDK

Send decision requests from your Node.js agent system

Download

Installation


  npm install @noxy-network/node-sdk@2.0.1
  # or
  yarn add @noxy-network/node-sdk@2.0.1
  # or
  pnpm add @noxy-network/node-sdk@2.0.1
  
Code

Quick Start


  import { initNoxyAgentClient, NoxyHumanDecisionOutcome } from '@noxy-network/node-sdk';

  const noxy = await initNoxyClient({
    endpoint: 'https://relay.noxy.network',
    authToken: '__your-api-token__',
    notificationTtlSeconds: 86400,
  });

  const proposedAction = {
    kind: 'propose_tool_call',
    tool: 'transfer_funds',
    args: { to: '__your-burn-address__', amountWei: '1' },
    title: 'Transfer 1 wei to the burn address',
    summary: 'The agent is requesting approval to send 1 wei to the burn address.',
  };

  const resolution = await noxy.sendDecisionAndWaitForOutcome(__your-wallet-address__, proposedAction, {
    maxWaitMs: 5 * 60 * 1000,
  });
  if (resolution?.outcome === NoxyHumanDecisionOutcome.APPROVED) {
    // your agent should proceed the action
  } else {
    // your agent should abort the action
  }