KIIEX – powered by KiiChain
  • Learn
    • What is KIIEX?
    • What is KiiChain?
    • KiiChain
      • Vision of KiiChain
      • Use Cases
      • Roadmap
      • Whitepaper
    • Tokenomics
      • Intro Coin Details
      • Coin Unlocking Schedule
      • Utility
      • Evergreen Model
    • Getting Started
      • Get a Wallet
      • Set Up a Web Wallet
      • Connect Wallet to Explorer App
  • Kii Ambassadors
  • CONNECT TO KIIEX
    • Set up your KIIEX Account
      • Upgrade your Account to Enterprise Level
    • Stablecoin FX Quick Start
      • Swap USDT to COPM with UI
    • KIIEX API's
      • System
      • User
      • Authentication
      • Models
  • BUILD ON KIICHAIN
    • Developer Hub
    • Testnet Oro
    • Endpoints - Cosmos
      • EVM
        • VM
        • ERC20
        • FeeMarket
      • IBC
      • Kiichain
        • TokenFactory
      • Cosmwasm
      • Cosmos
        • Auth
        • Authz
        • Bank
        • Tendermint
        • Consensus
        • Distribution
        • Evidence
        • Feegrant
        • Gov
        • Slashing
        • Staking
        • Tx
        • Upgrade
    • Developer Tools
      • RWA Protocol
      • Rust SDK
      • JS/TS SDK
        • Kiijs-evm
        • Kiijs-proto
        • Kiijs-utils
      • Deploy a smart contract
      • Deploy a dApp
      • Testnet faucet
    • Smart Contracts
    • Modules
      • TokenFactory
      • EVM
  • Precompiled contracts
  • Validate the Network
    • Getting Started
      • What is a delegator?
      • What is a validator?
    • Run a Validator / Full Node
      • Getting started
      • Step-by-Step Guide
        • Becoming a Validator
        • Recovering Legacy Addresses
      • Maintaining a validator
      • Incentive
      • Technical requirements
      • Validator Security
    • Economics
      • Staking Requirements
      • Delegation / Staking
      • Rewards
      • Block Rewards Formula
      • APR
    • Delegator Information
      • Choosing a validator
      • Directives of delegators
      • Incentive to stake
      • Security considerations
      • Risks to consider
Powered by GitBook
LogoLogo
On this page
  • @kiichain/kiijs-utils
  • Installation
  • Bech32 conversion
  • ETHSECP signer

Was this helpful?

Export as PDF
  1. BUILD ON KIICHAIN
  2. Developer Tools
  3. JS/TS SDK

Kiijs-utils

@kiichain/kiijs-utils

Typescript library containing general utility functions for interacting with Kiichain.

Installation

yarn add @kiichain/kiijs-utils @kiichain/kiijs-proto

Bech32 conversion

The package has utils to easen up conversion between hex and bech32 addresses. They can be used like this:

import { HexToBech32, Bech32ToHex } from '@kiichain/kiijs-utils'

const kiiAddress = HexToBech32("0xyourhex")

const evmAddress = Bech32ToHex("kiiYouraddress)

ETHSECP signer

Some wallets do not recognize the ETHSECP256-1 PubKey signatures. We made a couple helpers to utilize it without problems.

Signing a transaction

  1. Create the SigningStargateClient with the correct type

import { ethsecpAccountParser, signWithEthsecpSigner } from '@kiichain/kiijs-utils';

// Start the client connection
// The stargate client must use the custom account parser
// This is necessary to handle the ethsecp256k1 PubKey format in queries
const client = await SigningStargateClient.connectWithSigner(
  RPC_ENDPOINT,
  offlineSigner,
  {
    accountParser: ethsecpAccountParser,
  }
);

The signing client must use a custom account parser to handle the ethsecp256k1 public key format. This is crucial for correctly signing transactions.

  1. Sign the transaction with a custom pubkey

// This is the important bit
// This signs the transaction using the ethsecp256k1 signer
// It basically rewrite the Pubkey to the ethsecp256k1 format
const txRaw = await signWithEthsecpSigner(
  client,
  offlineSigner,
  CHAIN_ID,
  address,
  [msgSend],
  "This is a sample transaction memo",
  KEPLR_CHAIN_INFO.feeCurrencies[0].gasPriceStep.high,
  1.5
);
  1. Broadcast the signed transaction

const receipt = await client.broadcastTx(txRaw);

A full example can be found [here](https://github.com/KiiChain/keplr-tx-template/blob/main/src/App.tsx)
PreviousKiijs-protoNextDeploy a smart contract

Last updated 13 days ago

Was this helpful?