You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pnpm add autonity-sdk ethers
# Note: pnpm does not automatically install peer dependencies, so you also need to install ethers:
Basic Usage (View-only)
import{Contract}from'autonity-sdk';// Create a contract instance (read-only)constcontract=newContract({rpcUrl: "https://rpc.autonity.org",contractAddress: "0x..."});
Using Private Key (Automatic Signer)
import{Contract}from'autonity-sdk';// Create a contract instance with private keyconstcontract=newContract({rpcUrl: "https://rpc.autonity.org",contractAddress: "0x...",privateKey: "0xYOUR_PRIVATE_KEY"});
Using Custom Signer
import{Contract}from'autonity-sdk';import{ethers}from'ethers';// Create a provider and signerconstprovider=newethers.JsonRpcProvider('https://rpc.autonity.org');constsigner=newethers.Wallet('0xYOUR_PRIVATE_KEY',provider);// Create a contract instance with custom signerconstcontract=newContract({provider: provider,contractAddress: '0x...',signer: signer});
Configuration Options by Mode
1. View-only (read-only)
Option
Type
Required
Description
rpcUrl
string
Yes
RPC endpoint URL for read-only operations
contractAddress
string
Yes
Autonity contract address
privateKey
string
No
Not used in read-only mode
signer
ethers.Signer
No
Not used in read-only mode
2. Using Private Key (automatic signer)
Option
Type
Required
Description
rpcUrl
string
Yes
RPC endpoint URL for sending transactions
contractAddress
string
Yes
Autonity contract address
privateKey
string
Yes
Private key used to create signer
signer
ethers.Signer
No
Do not use together with privateKey
3. Using Signer (custom signer)
Option
Type
Required
Description
provider
ethers.Provider
Yes
Provider associated with the signer
contractAddress
string
Yes
Autonity contract address
signer
ethers.Signer
Yes
Pre-configured ethers signer for transactions
rpcUrl
string
No
Optional if signer already has a provider
privateKey
string
No
Do not use together with signer
About
Autonity SDK is a JavaScript library for interacting with Autonity network