TypeScript SDK for interacting with Imuachain - a Cosmos SDK chain with EVM compatibility (Ethermint). This SDK provides utilities for account management, transaction building, signing, and querying Imuachain modules.
- Custom Account Parser: Handles Imuachain's
EthAccounttype (Ethermint-based) - ethsecp256k1 Signer: Creates signers where Cosmos address matches EVM address
- Transaction Building: Simplified transaction construction and signing
- Query Client: Scalable module-based query clients for all Imuachain modules
- Address Conversion: Utilities for converting between EVM hex and Cosmos bech32 addresses
- Type Safety: Full TypeScript support with generated protobuf types
yarn add @imua-xyz/imuajsimport { ImuachainClient } from "@imua-xyz/imuajs";
import { MessageComposer } from "@imua-xyz/imuajs/imuachain/operator/v1/tx.registry";
import { RegisterOperatorReq } from "@imua-xyz/imuajs/imuachain/operator/v1/tx";
import { CommissionRates } from "@imua-xyz/imuajs/cosmos/staking/v1beta1/staking";
// Initialize client
const client = new ImuachainClient({
rpcEndpoint: "http://localhost:26657",
chainId: "imuachainlocalnet_232-1",
prefix: "im",
});
// Initialize signer from private key
await client.initSigner("0x...");
// Get signer addresses
const cosmosAddress = client.getSignerAddress(); // e.g., "im1..."
const evmAddress = client.getSignerEvmAddress(); // e.g., "0x..."
// Build and send transaction
const registerOperatorReq: RegisterOperatorReq = RegisterOperatorReq.fromPartial({
fromAddress: cosmosAddress,
info: {
earningsAddr: cosmosAddress,
approveAddr: cosmosAddress,
operatorMetaInfo: "my-operator",
commission: {
commissionRates: CommissionRates.fromPartial({
rate: "0.1",
maxRate: "0.2",
maxChangeRate: "0.01",
}),
updateTime: new Date(),
},
},
});
const message = MessageComposer.encoded.registerOperator(registerOperatorReq);
const txHash = await client.sendTx([message], {
gasLimit: "200000",
gasPrice: "10",
feeDenom: "hua",
});
console.log("Transaction hash:", txHash);
// Query operator info
const operatorInfo = await client.getOperatorInfo(cosmosAddress);
console.log("Operator:", operatorInfo.earnings_addr);
// Or use the scalable query client
const queries = client.queries;
const assetInfo = await queries.assets.queStakingAssetInfo({ assetId: "1" });
const stakerBalance = await queries.assets.queryStakerBalance({
stakerId: "0x...",
assetId: "1",
});- Package README - Overview and quick start
- SDK Client README - Complete API documentation
- Query Scalability Guide - Understanding the query client architecture
- SDK Summary - Overview of the SDK structure
See the packages/imuachain/examples/ directory for complete examples:
register-operator-sdk.ts- Register an operator using the SDKquery-examples.ts- Various query examples using the scalable query clientregister-operator.ts- Low-level example using cosmjs directly
This is a monorepo containing:
packages/imuachain- Main SDK package (@imua-xyz/imuajs)- TypeScript client SDK
- Generated protobuf types for all Imuachain modules
- Query clients for all modules
- Transaction building utilities
- Node.js 18+
- yarn
# Install dependencies
yarn install
# Build all packages
yarn build
# Run tests
yarn testThe SDK uses Telescope to generate TypeScript types from protobuf definitions.
cd packages/imuachain
# Download protobuf files
yarn download-protos
# Generate TypeScript types
yarn codegen
# Build
yarn build# Unit tests (fast, no node required)
yarn test:unit
# Integration tests (requires local Imuachain node)
yarn test:integration
# All tests
yarn testSee packages/imuachain/TESTING.md for detailed testing instructions.
See PUBLISHING.md for detailed publishing instructions.
Quick steps:
- Ensure GitHub repository exists:
https://github.com/imua-xyz/imuajs - Build the package:
cd packages/imuachain && yarn build - Publish:
npm publish --access public
MIT - See LICENSE file for details.
- GitHub: https://github.com/imua-xyz/imuajs
- npm: https://www.npmjs.com/package/@imua-xyz/imuajs
- Issues: https://github.com/imua-xyz/imuajs/issues
- Imuachain - The Imuachain blockchain node
- Telescope - TypeScript transpiler for Cosmos SDK Protobufs
Built by the Imua team.
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.