Initia.js is a TypeScript-written JavaScript SDK tailored for the Initia blockchain, enhancing the development experience with user-friendly TypeScript definitions and integration with Initia's core data structures.
Main Features
Improved TypeScript Definitions: Offers comprehensive integration with Initia core data structures for an enhanced developer experience.
Core Layer: Includes key management, BCS serialization, and support for initia.proto.
Client Layer: Facilitates API request generation and LCD provider interaction.
Prerequisites
To use Initia.js effectively, you must have the following installed:
Installation
To install Initia.js, run the following command:
npminstall@initia/initia.js
Examples
LCD Client
The LCD (Light Client Daemon) class enables easy interaction with the Initia blockchain.
import { LCDClient } from'@initia/initia.js'constlcd=newLCDClient('https://lcd.[chain-id].initia.xyz', { chainId:'[chain-id]', gasPrices:'0.15uinit',// default gas prices gasAdjustment:'2.0',// default gas adjustment for fee estimation})
Adjust gasPrices and gasAdjustment according to current network conditions for optimal transaction processing.
Key Management
The SDK provides an abstract key interface for transaction signing and address/public key derivation.
viewfunction() : query the move contract view functions
constres=awaitlcd.move.viewFunction('0x1',// owner of the module'dex',// name of the module'get_swap_simulation',// function name ['0x1::native_uinit::Coin','0x1::native_uusdc::Coin'],// type arguments [bcs.u64().serialize(10000).toBase64()] // arguments)