Cross-chain KLIMA DAO Staking

Introduction

The KLIMA DAO Staking block is an example custom smart contract interaction to achieve a business specific goal, using the Etherspot BUIDLER Component.

🔗 Skip straight to Building your own block

In this case, this block allows users to stake directly into sKLIMA from any token on any blockchain. This is achieved by using the built-in functionality that Etherspot provides to fetch crosschain swap routes and execute transactions.

When selecting a new transaction, the user can select the KLIMA Staking block:

The user can select any asset they own on any chain, and the following process will take place:

From the flow above, the following business logic is performed:

  1. The user selects a blockchain

  2. The owned assets from the selected blockchain are loaded

  3. The user selects an amount of their token on their selected blockchain that they would like to use to stake into the KLIMA DAO contract

  4. This information is passed to the Etherspot SDK for crosschain offers, and a list of possible crosschain swapping routes are returned

  5. The business logic of the KLIMA block is programmed to select the best offer on behalf of the user

  6. This crosschain swap transaction is added to the transaction batch

  7. A new transaction is programmed to take the swap amount and asset and stake it into the KLIMA DAO staking contract

  8. This contract staking action is added to the transaction batch

  9. If the user has selected to receieve their staked KLIMA into a key wallet addess:

    1. A new transaction is programmed to send the sKLIMA to the desired address and added to the batch.

  10. The batch is executed.

Implementation

Copy and paste the code below to see the KLIMA Staking Block in action.

import {
  Etherspot,
  TRANSACTION_BLOCK_TYPE,
} from "@etherspot/react-transaction-buidler";

// ...

return (
  <Etherspot
    defaultTransactionBlocks={[{ type: TRANSACTION_BLOCK_TYPE.KLIMA_STAKE }]}
  />
);

Building your own block

Have a look at the open-source Etherspot BUIDLER Component repository here.

🔗 https://github.com/etherspot/etherspot-react-transaction-buidler

See how the KLIMA Staking Block is built here:

🔗 https://github.com/etherspot/etherspot-react-transaction-buidler/blob/develop/src/components/TransactionBlock/KlimaStakingTransactionBlock.tsx

Last updated