SDK functions on Near protocol


Craft a stake transaction.

The amount to stake is in NEAR.

const tx = await k.near.craftStakeTx('account_id', 'wallet_address', 'pool_id', 1);


Craft an unstake transaction. Once unstaked, your token will be available for withdrawals after ~36 to 48h (3 full epochs).

The amount to unstake is optional and in NEAR, the whole stake balance will be unstaked if no amount is given.

const tx = await k.near.craftUnstakeTx('wallet_address', 'pool_id', 1);


Craft a withdraw transaction. The amount to withdraw must first be unstaked and available before you can withdraw it.

The amount to withdraw is optional and in NEAR, the whole stake balance will be withdrawn if no amount is given.

const tx = await k.near.craftWithdrawTx('wallet_address', 'pool_id', 1);


Sign a transaction by specifying the integration and the crafted transaction.

Here is an example showing how to sign a transaction with a fireblocks vault.

Checkout the setup fireblocks documentation to setup your vault.

import { Integration } from "@kilnfi/sdk/lib/types/integrations";
const fs = require('fs');
const apiSecret = fs.readFileSync(__dirname + '/fireblocks_secret.key', 'utf8');

const vault: Integration = {
      provider: 'fireblocks',
      fireblocksApiKey: 'YOUR_API_USER_KEY', // your fireblocks API user key
      fireblocksSecretKey: apiSecret, // your fireblocks private key (generated with your CSR file and your API user)
      vaultId: 7 // your fireblocks vault id
const txSigned = await k.near.sign(vault, tx);


Broadcast a signed transaction.

const txHash = await k.near.broadcast(txSigned);

Get transaction status

Get the transaction status of a broadcasted transaction by providing its transaction hash and the pool id that received transaction.

const status = await k.near.getTxStatus('tx_hash', 'pool_id');

Decode transaction

Decode a serialized transaction previously crafted. You can use this to get more information about a transaction prior to broadcast it such as the gas fees used, the function parameters etc.

const decodedTx = await k.near.decodeTx('tx_serialized');

Get stakes

Get stakes real time data. You can get stakes by Kiln accounts, by stake accounts (poolId_walletId) or by wallets.

const stakes = await k.near.getStakesByAccounts(['5dcd8897-4fe7-401a-9ad8-3a15dae1fbe8']);
const stakes = await k.near.getStakesByStakeAccounts(['kiln.pool.f863973.m0_373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e']);
const stakes = await k.near.getStakesByWallets(['373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e']);

Get rewards

Get historical rewards data by day. You can get rewards aggregated by Kiln accounts, by stake accounts (poolId_walletId) or by wallets.

const rewards = await k.near.getRewardsByAccounts(['5dcd8897-4fe7-401a-9ad8-3a15dae1fbe8']);
const rewards = await k.near.getRewardsByStakeAccounts(['kiln.pool.f863973.m0_373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e']);
const rewards = await k.near.getRewardsByWallets(['373c6f8e84c6822a9f87035f65cccf899eef3fcdee61077041a93e1805bab24e']);

Get network stats

Get some network stats.

const stats = await k.near.getNetworkStats();

Last updated