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 phrase rather than the private key, as it is the seed phrase that is needed as an 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
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.
You will need a Depasify account in order to make fiat transactions using the Kima Transaction back end. Add the Depasify API key to your environment variables as DEPASIFY_API_KEY
.
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
, /uuid
or /kyc
endpoints.
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
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
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
GET /uuid
This GET request will generate a UUID for a fiat payment session, which uses the Depasify API.
POST /kyc
Once you have generated the UUID above, it can be used to return the KYC status. Uses the Depasify API.
{ "uuid": "123e4567-e89b-12d3-a456-426614174000" }
Last updated