Kima Network Documentation
  • What is Kima?
  • Supported blockchains
  • Supported tokens
  • Supported fiat currencies and payment methods
  • Adding Kima to your wallet
  • Try Kima with the Demo App
    • The Kima Light Demo App
    • The Kima Advanced Demo App
    • Kima Faucets
    • Kima Block Explorer
  • Become a Kima validator
    • Hardware and operating system requirements
    • Installation
    • Appendix
  • Become a Kima delegator
    • Benefits
    • How does it work?
    • Preparations
    • Delegate
    • Reclaim delegation
  • Become a liquidity provider
    • Benefits
    • Supported blockchains
    • Prepare to provide liquidity
    • Deposit assets in Kima pools
    • Withdraw liquidity
  • Kima governance
    • Draft a proposal
    • On-chain proposal
    • Off-chain proposal
    • References
  • The Kima SDK
    • Kima Use Cases for Developers
    • The Kima Transaction Back End
    • The Kima Transaction Widget
      • Installation
      • React
      • NextJS
      • Payment Mode
      • Bridge Mode
      • Status Mode
      • Configuration Options
    • Upgrading
      • v1.4.x
    • Using the Kima SDK Without the Widget
      • Approval
      • Submitting the Transaction
      • Getting the Transaction Status
    • v1.4
      • Credit Card Transactions
      • Kima Use Cases for Developers
      • The Kima Transaction Back End
      • The Kima Transaction Widget
        • Installation
        • React
        • NextJS
        • Payment Mode
        • Bridge Mode
        • Status Mode
        • Configuration Options
      • Upgrading
        • v1.4.x
      • Using the Kima SDK Without the Widget
        • Transaction Data
        • Message Signing
        • Approval
        • Submitting the Transaction
        • Getting the Transaction Status
  • Further reading
  • Legal
    • Terms and conditions
    • Privacy policy
    • Disclaimer
  • FAQ
Powered by GitBook
On this page
  • Calculate the Submit Amount
  • Using the Kima Backend
  • Using the Kima API
  • Submitting the Transaction
  • Chain Names
  • Get Transaction Id
  • Validation
Export as PDF
  1. The Kima SDK
  2. Using the Kima SDK Without the Widget

Submitting the Transaction

Once the user has approved the token transfer, it’s time to construct the submit request to the Kima Transaction Backend.

Calculate the Submit Amount

Using the Kima Backend

Use the submitAmount property returned from the /submit/fees endpoint.

Using the Kima API

The submit amount should always be the amount the target addreess will receive. This means the submit amount needs to be adjusted based on whether the fees are deducted from the amount or not.

function getSubmitAmount(
  amount: bigint,
  fees: bigint,
  deductFee: boolean
): bigint {
  return deductFee ? amount - fees : amount;
}

Submitting the Transaction

POST /submit Request Body:

  • originAddress (Address): sending user address

  • originChain (string): sending chain

  • originSymbol (string): sending token symbol

  • targetAddress (Address): receiving user address

  • targetChain (string): receiving chain

  • targetSymbol (string): receiving token symbol

  • amount (bigint string): amount of token received by the target address

  • fee (bigint string): amount of token that Kima consumes to pay gas fees for pulling & releasing token transactions

  • decimals (number): the number of decimals for the bigint amounts

  • For Bitcoin transactions:

    • Set these to the empty string or zero for non-BTC transactions

    • htlcCreationHash (string): the tx hash locking the funds in the HTLC

    • htlcCreationVout (number): the output index of the locked funds in the HTLC creation transaction

    • htlcExpirationTimestamp (string): the timestamp when the HTLC contract expires and the user can reclaim the funds locked there

    • htclVersion (string)

    • senderPubKey (string): for bitcoin transactions this is the public key of the sender

Success Response:

  • height: number

  • txIndex: number

  • code: number: error code; will be zero when successful

  • transactionHash: string

  • events: Event[]

    • type: string

    • attributes: Attribute[]

      • key: string

      • value: string

  • rawLog?: string

  • data?: MsgData[]

  • msgResponses: Uint8Array

  • gasUsed: bigint

  • gasWanted: bigint

Chain Names

Get Transaction Id

The transaction Id will be needed to get the transaction status. The following code can be used to extract the Id from the submit response.

export function getTransactionId(submitResult: any): number {
  let txId = -1;
  if (result?.code !== 0) {
    return txId;
  }

  for (const event of result.events) {
    if (event.type === "transaction_requested") {
      for (const attr of event.attributes) {
        if (attr.key === "txId") {
          txId = attr.value;
        }
      }
    }
  }

  return txId;
}

Validation

If provided, the Kima Backend will use the url defined in the ENV var COMPLIANCE_URL to get the risk score for the origin and target user addresses. If the score is anything other than low it will respond with a 500 error.

PreviousApprovalNextGetting the Transaction Status

Last updated 17 days ago

See the short names in the section.

Supported Blockchains