ADA

SDK functions on Cardano protocol

Stake

Craft a delegation transaction to the given pool id.

It also links your stake to the kiln account id provided.

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

Withdraw rewards

Craft a withdraw rewards transaction. Rewards on Cardano are automatically added to your stake balance but you need to withdraw them in order to spend or exchange them.

The amount to withdraw is in ADA.

const tx = await k.ada.craftWithdrawRewardsTx('wallet_address', 1);

Unstake

Craft an undelegate transaction.

const tx = await k.ada.craftUnstakeTx('wallet_address');

Sign

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.ada.sign(vault, tx);

Broadcast

Broadcast a signed transaction.

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

Get transaction status

Get the transaction status of a broadcasted transaction by providing its transaction hash.

const status = await k.ada.getTxStatus('tx_hash');

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.ada.decodeTx('tx_serialized');

Get stakes

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

const stakes = await k.ada.getStakesByAccounts(['771254de-ac5a-4911-afdf-1d5b7e802dc9']);
const stakes = await k.ada.getStakesByStakeAddresses(['stake_test1uz59v5z9cjgs8dfp5wp8lajtnzyfx59z9756pdwv7u4j0xcvwv4gp']);
const stakes = await k.ada.getStakesByWallets(['addr_test1qpy358g8glafrucevf0rjpmzx2k5esn5uvjh7dzuakpdhv4g2egyt3y3qw6jrguz0lmyhxygjdg2ytaf5z6ueaety7dsmpcee5']);

Get rewards

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

const rewards = await k.ada.getRewardsByAccounts(['771254de-ac5a-4911-afdf-1d5b7e802dc9']);
const rewards = await k.ada.getRewardsByStakeAddresses(['stake_test1uz59v5z9cjgs8dfp5wp8lajtnzyfx59z9756pdwv7u4j0xcvwv4gp']);
const rewards = await k.ada.getRewardsByWallets(['addr_test1qpy358g8glafrucevf0rjpmzx2k5esn5uvjh7dzuakpdhv4g2egyt3y3qw6jrguz0lmyhxygjdg2ytaf5z6ueaety7dsmpcee5']);

Get network stats

Get some network stats.

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

Last updated