Submitting the Transaction

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

Submitting the Transaction

POST /submit Request Body:

  • originAddress (Address): sending user address

  • originChain (string): sending chain

  • targetAddress (Address): receiving user address

  • targetChain (string): receiving chain

  • targetSymbol (string): receiving token symbol

  • amount (number): amount of token to transfer

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

  • 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

See the short names in the Supported Blockchains section.

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;  
}

Authentication

Before calling submit a JWT token must be obtained with the body payload. The JWT will be checked against the request body and if it does not match will respond with a 500 error.

Validation

If provided, the Kima Backend will use the Explorisk url defined in the ENV var XPLORISK_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.

Last updated