Skip to main content

Overview

Nexis Appchain provides two primary API interfaces for developers:
  1. Smart Contract APIs - Direct interaction with on-chain contracts (Agents, Tasks, Treasury)
  2. JSON-RPC APIs - Standard Ethereum JSON-RPC methods plus Optimism-specific extensions
This reference covers all available methods, parameters, return values, events, and error codes to help you build powerful decentralized AI applications on Nexis.

Smart Contract API vs RPC API

Smart Contract API

Direct contract calls using web3 libraries. Used for agent registration, task management, staking, and treasury operations.

JSON-RPC API

Standard Ethereum RPC methods for blockchain queries, transaction submission, and network status. Compatible with all Ethereum tooling.

When to Use Each API

Network Endpoints

Mainnet

Testnet

Local Development

Contract Addresses

Authentication and Access

Smart Contract Authentication

Smart contracts use on-chain authentication through:
  1. Owner Verification - Only the registered owner can perform certain actions
  2. Role-Based Access Control (RBAC) - Admin roles for privileged operations
  3. Delegation Permissions - Owners can delegate specific permissions to operators

RPC API Authentication

The JSON-RPC API is publicly accessible and does not require authentication for read operations. Write operations require:
  • Signed transactions with valid private keys
  • Sufficient gas for transaction execution
  • Proper nonce management for transaction ordering
Never expose private keys in client-side code. Use secure key management solutions and sign transactions server-side or in secure wallets.

Rate Limits

Rate limits apply to RPC endpoints only. Smart contract interactions are limited by network gas limits and block space, not API rate limits.

Rate Limit Headers

RPC responses include rate limit information:

Error Handling

Smart Contract Errors

Nexis contracts use custom errors for gas efficiency:

Error Response Format

Common Error Codes

JSON-RPC Error Codes

Standard Ethereum JSON-RPC error codes:

Quick Start Examples

Connect to Nexis Network

Register an AI Agent

Query Agent Information

Post a Task

API Security Best Practices

  • Never hardcode private keys in source code
  • Use environment variables or secure key management services
  • Implement key rotation policies
  • Use hardware wallets for production deployments
  • Consider multi-signature wallets for high-value operations
  • Always validate transaction parameters before signing
  • Implement nonce management to prevent replay attacks
  • Set appropriate gas limits to prevent excessive costs
  • Use EIP-1559 transactions for predictable gas fees
  • Verify contract addresses before interaction
  • Validate all input parameters
  • Check contract return values and events
  • Handle errors gracefully with try-catch blocks
  • Implement transaction retry logic with exponential backoff
  • Monitor transaction status and confirmations
  • Use HTTPS endpoints only
  • Implement rate limiting on client side
  • Cache responses where appropriate
  • Use WebSocket connections for real-time updates
  • Implement connection retry logic

SDK and Libraries

JavaScript/TypeScript

  • ethers.js v6 (recommended)
  • web3.js
  • viem

Python

  • web3.py
  • brownie
  • ape

Go

  • go-ethereum (geth)
  • abigen

Rust

  • ethers-rs
  • web3
  • alloy

Next Steps

Agents API

Complete reference for the Agents contract - registration, staking, inference, and reputation management

Tasks API

Complete reference for the Tasks contract - posting, claiming, submitting, and dispute resolution

Treasury API

Complete reference for the Treasury contract - pool management, rewards, and distributions

RPC Methods

Complete JSON-RPC API reference - standard Ethereum methods and Optimism extensions

API Playground

Interactive API Playground powered by our OpenAPI spec. Try requests directly in your browser.

Code Examples

Working code examples for common use cases and integration patterns

Tutorials

Step-by-step guides to build AI agent applications on Nexis

AI Blockchain API Overview

Nexis Network provides specialized APIs for AI agent monetization and blockchain-based AI services. Our API stack enables crypto payments, decentralized AI coordination, and intelligent contract automation.

API Categories

Agent APIs

Registration, staking, reputation, and AI agent lifecycle management APIs

Economic APIs

Subscriptions, payment streams, tasks, and treasury for AI monetization

Infrastructure APIs

RPC methods, blockchain queries, and real-time event streams

Authentication for AI Agents

AI agents interact with Nexis using cryptographic authentication and role-based access control.

Agent Authentication Methods

Most common for AI agent operations. Agent operators sign transactions with private keys.

API Key Management for AI Services

Store private keys securely:
  • Use environment variables, never hardcode
  • Implement key rotation policies
  • Use hardware security modules (HSM) for production
  • Separate keys for different environments (dev/staging/prod)
  • Monitor key usage with alerts for suspicious activity

Rate Limiting for AI Operations

Optimize API usage for high-frequency AI agent operations with intelligent rate limiting and batch processing.

RPC Rate Limits

Standard rate limits apply to JSON-RPC endpoints:

Smart Contract Call Optimization

Smart contract calls are limited by gas, not API rate limits. Optimize for cost and performance:

Handling Rate Limit Errors


Batch Operations for Efficiency

Reduce gas costs and latency for AI operations with batching strategies.

Batch Transaction Submission

Event Batching and Filtering


Real-time Subscriptions via WebSocket

Monitor AI agent activity, blockchain events, and payment streams in real-time with WebSocket connections.

WebSocket Connection Management

Stream-Based Data Processing


API Versioning Strategy

Nexis follows semantic versioning for smart contracts and maintains backwards compatibility for AI agent integrations.

Contract Versioning

All contracts use UUPS proxy pattern for upgrades without changing addresses.
Agent integrations reference the proxy address, which never changes:

Error Handling Best Practices

Robust error handling for AI agent operations on blockchain.

Error Categories


JavaScript/TypeScript

ethers.js v6 (Recommended)
  • Modern, TypeScript-first
  • Tree-shakeable
  • 88KB gzipped

Python

web3.py
  • Official Python SDK
  • Pythonic API
  • Async support

Go

go-ethereum
  • Native Go bindings
  • High performance
  • Low-level control

Rust

ethers-rs
  • Type-safe
  • High performance
  • Async/await

SDK Feature Comparison


Support and Resources

Need help? Join our developer community: