Ethereum (ETH)

SDK functions on Ethereum protocol

Stake

Stake a multiple of 32 ETH in a single transaction.

This call generate validation keys on our system and links your Kiln account to them.

These validation keys are automatically deployed after the deposit transaction is made.

const tx = await k.eth.craftStakeTx('account_id', 'wallet_address', 32);

Unstake

Craft exit request transactions. We watch these transactions and will exit your validators on your behalf. Exiting a validator can take a couple of days depending on the size of the exit queue.

You can exit multiple validators in one transaction.

const tx = await k.eth.craftExitRequestTx('wallet_address', ['validator_address_1', 'validator_address_2']);

Sign and broadcast

On ETH, you have two options for signing and broadcasting transactions.

Fireblocks contract call

The method is usually preferred as it does not require the Fireblocks raw signing feature and allows you to leverage Fireblocks policies.

For this method to work you will need to whitelist the contract address that you are interacting with. When staking ETH with Kiln, it is interacting with our batch deposit contract (testnet / mainnet).

Once the contract is whitelisted in Fireblocks, you should be able to retrieve the destination id associated with it (in the fireblocks URL or via their API). This id needs to be in the Integration configuration object.

Here is an example showing how to sign and broadcast 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
      fireblocksDestinationId: '07df91b4-7788-4833-a8f4-428facef68cc', // your fireblocks whitelisted destination id
};
const txSigned = await k.eth.signAndBroadcast(vault, tx);

With this method, the transaction is signed and broadcasted through Fireblocks.

Fireblocks raw signing

When using the Fireblocks raw signing feature, you need to make two calls to our SDK, the first to sign the transaction and the second to broadcast it via our API.

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.eth.sign(vault, tx);
const txHash = await k.eth.broadcast(txSigned);

Get transaction status

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

const status = await k.eth.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.eth.decodeTx('tx_serialized');

Get stakes

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

const stakes = await k.eth.getStakesByAccounts(['771254de-ac5a-4911-afdf-1d5b7e802dc9']);
const stakes = await k.eth.getStakesByValidators(['0xb682de189fd7e6c0e719ba4fcafa1f2ef878824df995617c11a656b99e88fdaf0bd696f48baf35ea8114dfaa67c9bf54']);
const stakes = await k.eth.getStakesByWallets(['0xbc86717BaD3F8CcF86D2882A6bC351C94580a994']);

Get rewards

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

const rewards = await k.eth.getRewardsByAccounts(['771254de-ac5a-4911-afdf-1d5b7e802dc9']);
const rewards = await k.eth.getRewardsByValidators(['0xb682de189fd7e6c0e719ba4fcafa1f2ef878824df995617c11a656b99e88fdaf0bd696f48baf35ea8114dfaa67c9bf54']);
const rewards = await k.eth.getRewardsByWallets(['0xbc86717BaD3F8CcF86D2882A6bC351C94580a994']);

Get network stats

Get some network stats.

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

Get Kiln stats

Get Kiln APRs.

const stats = await k.eth.getKilnStats();

Last updated