The Kima Transaction Back End

This is a web server that works as middleware between the Kima Transaction Widget and Kima Chain. Once it receives a transaction request from the widget, it will submit a transaction to Kima Chain signed by a local wallet.

The server is an Express application and requires minimal setup. Here are the instructions:

Create a wallet for development purposes

We recommend Keplr, which is a widely used wallet for blockchains within the Cosmos ecosystem.

Install it from here and make sure you back it up by saving the seed phrase.

You will need to record the mnemonic seed phrase rather than the private key, as the seed phrase is used as an environment variable.

Get some KIMA tokens to use for transaction fees

If you are developing on the KIMA testnet, you can acquire test KIMA tokens from our faucet site.

Follow the instructions here if you have not used a faucet before.

Clone the repo at:

https://github.com/kima-finance/kima-transaction-backend

Set your environment variables

If you are using Docker, you can add these to the docker-compose; otherwise, create an .env file with the following key pairs:

Copy

PORT=3001
KIMA_BACKEND_MNEMONIC=XXXXXXXXX
KIMA_BACKEND_SECRET=XXXXXXXX
KIMA_BACKEND_NODE_PROVIDER=https://rpc.sardis.kima.network
KIMA_BACKEND_NODE_PROVIDER_QUERY=https://api.sardis.kima.network
XPLORISK_URL=XXXXXXXX

A few notes about these environment variables:

KIMA_BACKEND_MNEMONIC is the seed phrase from the wallet you installed.

KIMA_BACKEND_SECRET is the secret for generating JSON Web Tokens. Read more about JWT here if you have not used them before.

For checking whether transactions involve risky wallets. you will need an xplorisk account. The Xplorisk Lambda endpoint should be added to your .env file as XPLORISK_URL.

Neither of these dependencies are mandatory as long as you do not want to invoke the /compliant endpoint.

Install and start

You can run:

npm i

then

npm run dev

but the easiest way to get up and running without any dependency issues is with Docker. Use docker-compose.yml for dev, docker-compose-prod.yml for prod.

Start the server with:

docker compose up

Test the installation

In your terminal, run the following command:

Copy

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://localhost:3001/auth

The server should respond with a valid authtoken with a five-second expiry.

Available routes

POST /auth

The Kima Transaction Widget sends a POST request to this endpoint before it submits a transaction request. Returns JWT as cookie which has 5 seconds of life time. This cookie will be expired after 5 seconds. Kima Transaction Widget will call the second endpoint right after it receives JWT Auth Token.

POST /submit

This is a POST request that submits a cross-chain transaction using the developer wallet whose details are stored. Before the /submit endpoint is called, the JWT will first be validated.

The reponse object will contain a transaction ID which can be used to track the success of the submission.

An example of the request body that should be sent:

Copy

{
  "originAddress": "0x123...",
  "originChain": "Ethereum",
  "targetAddress": "0x456...",
  "targetChain": "Avalanche",
  "symbol": "ETH",
  "amount": "1.0",
  "fee": "0.01"
}

POST /compliant

This is a GET request which will return OK if the address is compliant. Note that this will work only if you have a Xplorisk account.

Copy

{
  "address": "0x1234..."
}

Last updated