1.0.5 • Published 2 years ago

@kilnfi/react-components v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Overview

This is a React components library that can be used to integrate staking components on different protocols.

ETH staking widget

The ETH staking widget allows you to stake on Kiln's deposit contract with a connected wallet.

Usage:

import { EthStakingWidget } from "@kilnfi/react-components";
import "@kilnfi/react-components/dist/cjs/index.css";

const App = () => {
  const config: Config = {
    apiUrl: '...', // KILN API URL
    apiKey: '...', // KILN API TOKEN
    accountId: '...', // KILN account id
    network: 'goerli', // goerli | mainnet
    chainId: 5, // network chain id
    onStartStaking: () => {
      //
    },
    onPendingTxSignature: (contractAddress, stakeAmount) => {
      //
    },
    onMiningDepositTx: () => {
      //
    },
    onUserRejectsDepositTx: () => {
      //
    },
    onError: (error) => {
      //
    },
    onSuccess: (receipt, stakeAmount) => {
      //
    },
    onReset: () => {
      //
    }
  };
  
  const provider = '' // A JsonRpcProvider (see: https://docs.ethers.io/v5/api/providers/jsonrpc-provider/)
  const account = '...' // connected wallet address
  
  return (
    <EthStakingWidget 
      config={config}
      provider={provider}
      account={account}
    >
      <EthStakingWidget.Header/>
      <EthStakingWidget.SelectAmount/>
      <EthStakingWidget.RewardsForecast/>
      <EthStakingWidget.Status/>
    </EthStakingWidget>   
  )
}

Reference:

EthStakingWidget

PropsTypeDescription
accountrequiredConnected wallet address (eg. '0x78693a6BCE41cB56D822FF039470DdAee0d47E72')
providerrequiredJsonRpcProvider (see: https://docs.ethers.io/v5/api/providers/jsonrpc-provider/)
configrequired
config.apiUrlrequiredKiln API URL
config.apiKeyrequiredKiln API key
config.accountIdrequiredKiln account id that will be associated with the stake.
config.networkrequired'goerli' or 'mainnet'
config.chainIdrequiredNetwork chain id: 5 or 1
config.onStartStakingoptionalFunction triggered when user clicks on "Stake now"
config.onPendingTxSignatureoptionalFunction triggered when the transaction signature is pending
config.onUserRejectsDepositTxoptionalFunction triggered when user rejects the transaction signature
config.onMiningDepositTxoptionalFunction triggered when transaction has been signed and is being mined
config.onSuccessoptionalFunction triggered when transaction has been mined successfully
config.onErroroptionalFunction triggered when there is an error while generating keys or if the transaction failed
config.onResetoptionalFunction triggered when component has been reset to initial state

EthStakingWidget.Header

Optional header.

EthStakingWidget.SelectAmount

Slider required to choose the amount to stake.

EthStakingWidget.RewardsForecast

Optional rewards forecast component.

EthStakingWidget.Status

Required bottom part of component with the different staking states, it includes the "Stake now" button.

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.53

3 years ago

0.0.52

3 years ago

0.0.51

3 years ago

0.0.50

3 years ago

0.0.49

3 years ago

0.0.48

3 years ago

0.0.47

3 years ago

0.0.46

3 years ago

0.0.45

3 years ago

0.0.44

3 years ago

0.0.43

3 years ago

0.0.42

3 years ago

0.0.41

3 years ago

0.0.40

3 years ago

0.0.39

3 years ago

0.0.38

3 years ago

0.0.37

3 years ago

0.0.36

3 years ago

0.0.35

3 years ago