Skip to main content

Quick Start

Get up and running with the Autonity SDK in minutes.

Installation

Install the Autonity SDK using your preferred package manager:

npm install autonity-sdk

Basic Usage (View-only)

For read-only operations, you only need to provide the RPC URL and contract address:

import { Contract } from 'autonity-sdk';

// Create a contract instance (read-only)
const contract = new Contract({
rpcUrl: "https://rpc.autonity.org",
contractAddress: "0x..."
});

Using Private Key (Automatic Signer)

When you need to send transactions, provide your private key and the SDK will automatically create a signer:

import { Contract } from 'autonity-sdk';

// Create a contract instance with private key
const contract = new Contract({
rpcUrl: "https://rpc.autonity.org",
contractAddress: "0x...",
privateKey: "0xYOUR_PRIVATE_KEY"
});

Using Custom Signer

For advanced use cases, you can provide your own configured signer:

import { Contract } from 'autonity-sdk';
import { ethers } from 'ethers';

// Create a provider and signer
const provider = new ethers.JsonRpcProvider('https://rpc.autonity.org');
const signer = new ethers.Wallet('0xYOUR_PRIVATE_KEY', provider);

// Create a contract instance with custom signer
const contract = new Contract({
provider: provider,
contractAddress: '0x...',
signer: signer
});

Configuration Options

The SDK supports three different configuration modes depending on your use case:

View-only (read-only)

For applications that only need to read data from the blockchain:

OptionTypeRequiredDescription
rpcUrlstringYesRPC endpoint URL for read-only operations
contractAddressstringYesAutonity contract address
privateKeystringNoNot used in read-only mode
signerethers.SignerNoNot used in read-only mode

Using Private Key (automatic signer)

For applications that need to send transactions with automatic signer creation:

OptionTypeRequiredDescription
rpcUrlstringYesRPC endpoint URL for sending transactions
contractAddressstringYesAutonity contract address
privateKeystringYesPrivate key used to create signer
signerethers.SignerNoDo not use together with privateKey

Using Custom Signer

For applications with pre-configured signers or advanced signing requirements:

OptionTypeRequiredDescription
providerethers.ProviderYesProvider associated with the signer
contractAddressstringYesAutonity contract address
signerethers.SignerYesPre-configured ethers signer for transactions
rpcUrlstringNoOptional if signer already has a provider
privateKeystringNoDo not use together with signer