0.1.6 • Published 10 months ago

@rulerunner/sdk v0.1.6

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

RuleRunner TypeScript/JavaScript SDK

Official TypeScript/JavaScript SDK for the RuleRunner API - a compliance-as-a-service platform for blockchain transactions.

Installation

npm install @rulerunner/sdk
# or
yarn add @rulerunner/sdk

Quick Start

import { RuleRunner } from '@rulerunner/sdk';

// Initialize the client with your API key
const client = new RuleRunner({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.rulerunner.io'
});

// Check if a transaction is compliant
const result = await client.isCompliant({
  from_address: '0x7FF9cFad3877F21d41Da833E2F775dB0569eE3D9',
  to_address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44f',
  amount: '10.0'
});

console.log(`Transaction is compliant: ${result.is_compliant}`);

// Verify a proof locally
if (!result.is_compliant && result.from_address_proof) {
  const isValid = await client.verifyProofLocally(
    '0x7FF9cFad3877F21d41Da833E2F775dB0569eE3D9',
    result.from_address_proof,
    result.merkle_root
  );
  console.log(`Local proof verification: ${isValid}`);
}

Features

  • Transaction compliance checking
  • Local proof verification
  • Health check endpoint
  • API key management
  • Rate limiting and quota tracking

API Reference

RuleRunner

const client = new RuleRunner({
  apiKey: string,
  baseURL?: string // Optional custom base URL
});

Methods

isCompliant

Check if a transaction is compliant with sanctions lists.

const result = await client.isCompliant({
  from_address: string,
  to_address: string,
  amount: string
});

verifyProofLocally

Verify a Merkle proof locally without making an API call.

const isValid = client.verifyProofLocally(
  address: string,
  proof: Array<{ position: 'left' | 'right'; hash: string }>,
  root: string
);

healthCheck

Check the health status of the API.

const status = await client.healthCheck();

Error Handling

The SDK throws custom errors for different error cases:

  • RuleRunnerAPIError: API-level errors (4xx, 5xx)
  • RuleRunnerConnectionError: Network/connection issues
  • RuleRunnerProofVerificationError: Invalid proof data

Development

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

License

MIT License

0.1.6

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago