IotaClient class provides a connection to the JSON-RPC Server and should be used for all read-only operations and transaction execution.
Basic Setup
Network URLs
The SDK provides helper functions to get default network URLs:Connection Options
- Devnet
- Testnet
- Localnet
- Custom URL
Connect to the IOTA Devnet for testing:
Client Configuration
TheIotaClient accepts a configuration object with the following options:
Using Custom Transport
You can provide a custom transport implementation:Client Methods Overview
TheIotaClient provides methods for:
Querying Data
getObject()- Fetch object detailsgetOwnedObjects()- Get objects owned by an addressgetCoins()- Fetch coins owned by an addressgetBalance()- Get coin balance for an addressgetTransaction()- Fetch transaction details
Transaction Execution
signAndExecuteTransaction()- Sign and execute a transactiondryRunTransactionBlock()- Simulate transaction executiondevInspectTransactionBlock()- Inspect transaction effects
Network Information
getCheckpoint()- Get checkpoint datagetProtocolConfig()- Get protocol configurationgetChainIdentifier()- Get chain identifier
Move Operations
getMoveFunctionArgTypes()- Get Move function argument typesgetNormalizedMoveFunction()- Get normalized Move functiongetNormalizedMoveModule()- Get normalized Move module
Example: Reading Account Data
Example: Executing Transactions
Making Custom RPC Calls
You can invoke any RPC method using thecall() method:
Error Handling
Best Practices
Reuse Client Instances
Reuse Client Instances
Create a single
IotaClient instance and reuse it throughout your application instead of creating new instances for each request.Validate Addresses
Validate Addresses
Always validate addresses before making API calls:
Handle Network Errors
Handle Network Errors
Implement proper error handling for network requests:
Next Steps
Reading Data
Learn how to query blockchain data
Transactions
Build and execute transactions
GraphQL Transport
Use GraphQL for advanced queries
API Reference
Explore the complete API