AR.IO SDK
The AR.IO SDK provides comprehensive tools for interacting with the AR.IO Network and Arweave ecosystem. Built with TypeScript, it offers type-safe interfaces for ArNS name management, gateway operations, and AO contract interactions.
Quick Start
Install the SDK
npm install @ar.io/sdk
Use the SDK
import { ARIO } from '@ar.io/sdk/node';
// Connect to mainnet
const ario = ARIO.mainnet();
// Get paginated gateway registry
const { items: gateways } = await ario.getGateways();
// Get paginated ArNS registry
const { items: records } = await ario.getArNSRecords();
console.log('Network data:', { gateways, records });
Install the SDK
npm install @ar.io/sdk
Install polyfills (required for web environments)
Polyfills are required for React web environments due to the use of crypto
, buffer
and process
types in the SDK's dependencies.
npm install --save-dev vite-plugin-node-polyfills
// vite.config.js
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
export default defineConfig({
plugins: [
nodePolyfills({
globals: {
Buffer: true,
global: true,
process: true,
},
}),
],
});
Configure your bundler (Webpack, Vite, Rollup, etc.) to provide polyfills for crypto
, process
, and buffer
. Refer to your bundler's documentation for polyfill configuration.
Use the SDK
import { ARIO } from '@ar.io/sdk/web';
// Connect to mainnet
const ario = ARIO.mainnet();
// Get paginated gateway registry
const { items: gateways } = await ario.getGateways();
// Get paginated ArNS registry
const { items: records } = await ario.getArNSRecords();
console.log('Network data:', { gateways, records });
<!DOCTYPE html>
<html>
<head>
<title>AR.IO SDK Example</title>
<script type="module">
// Polyfills are included in the minimized web bundle, so not necessary to import directly
import { ARIO } from 'https://unpkg.com/@ar.io/sdk';
// Connect to mainnet
const ario = ARIO.mainnet();
// Function to load AR.IO data
async function loadArioData() {
try {
// Get gateway information
const { items: gateways } = await ario.getGateways();
// Get ArNS records
const { items: records } = await ario.getArNSRecords();
// Display results
document.getElementById('results').innerHTML = `
<h3>Gateways: ${Object.keys(gateways).length}</h3>
<h3>ArNS Records: ${Object.keys(records).length}</h3>
<pre>${JSON.stringify({ gateways, records }, null, 2)}</pre>
`;
} catch (error) {
document.getElementById('results').innerHTML = `
<p style="color: red;">Error: ${error.message}</p>
`;
}
}
// Load data when page loads
window.addEventListener('load', loadArioData);
</script>
</head>
<body>
<h1>AR.IO SDK Example</h1>
<div id="results">
<p>Loading AR.IO data...</p>
</div>
</body>
</html>
API Reference & Documentation
API Reference
Complete API documentation for all SDK methods and classes
SDK Details
Detailed guides for ARIO contracts, ANT operations, and utilities
Core Features
ARIO Contract Operations
ArNS management, gateway discovery, and network configuration
ANT Contract Integration
Initialize, manage records, and transfer ANT ownership
Pagination & Utilities
Handle large datasets and token conversions efficiently
Token Operations
ARIO token conversions and management utilities
How is this guide?