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
      • Credit Card Transactions
      • 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
  • Message Structure
  • Example
  • Why sign a message?
Export as PDF
  1. The Kima SDK
  2. Using the Kima SDK Without the Widget

Message Signing

PreviousTransaction DataNextApproval

Last updated 1 month ago

In order to submit a transaction to the Kima blockchain, the user must sign a message containing the transaction details. This message is signed by the user's wallet and then included in data submitted to the Kima Transaction Backend /submit endpoint.

Message Structure

The message is a string that is signed by the user's wallet. It contains the following information:

  • Allowance amount: in whole tokens i.e. 10.23 not 10230000

  • Origin token symbol

  • Origin chain symbol: see the list of chain symbols in the section

  • Target address

  • Target chain symbol

Template:

I approve the transfer of {allowanceAmount} {originSymbol} from {originChain} to {targetAddress} on {targetChain}.

Example

Get the message to sign by calling the /submit/fees endpoint and selecting the appropriate version based on whether the user is paying fees from the origin or target chain.

To sign the message, the user's wallet must be connected and the message must be passed to the wallet client sign function. The following is an example of how to sign the message on EVM chains using .

import { Address } from "viem";
import { avalanche } from "viem/chains";

// however these are obtained in your app
import {  getUserWalletAddress, fetchFeeData, getUserFeeChoice } from "../utils";

const walletAddress = getUserWalletAddress()
const feeData = await fetchFeeData()
const isFeeFromOrigin = getUserFeeChoice() // boolean
const message = isFeeFromOrigin
  ? feeData.transactionValues.feeFromOrigin.message
  : feeData.transactionValues.feeFromTarget.message

const walletClient = createWalletClient({
    account: walletAddress as Address,
    chain: avalanche,
    transport: custom(window.ethereum),
})

 const signature = await walletClient.signMessage({
    account: walletAddress as Address,
    message
})

This signature will be passed to the options param of the /submit endpoint.

Why sign a message?

Signing a messge significantly improves security in the following ways:

  • The signature is cryptographically verifiable as coming from the user's wallet. This is proof that the user has authorized the transaction.

  • The transaction details cannot be modified without invalidating the signature. This prevents a "man in the middle" attack where the destination address is changed to the attacker's address.

Supported Assets
Viem