Front-end

Front-end of DApp usually connect to blockchain using web browser's extension. In this case, KardiaChain Wallet Chrome extension

Using Chrome extension

  1. After enabled, the extension will inject a web3 provider at window.kardiachain. This provider will be used by DApp to interact with blockchain

  2. Connect to the provider:

import Web3 from 'web3';

if (window.kardiachain) {
    window.web3 = new Web3(window.kardiachain);
    if (window.kardiachain.isKaiWallet) {
        window.kardiachain.enable();
    }
    
    // Send a transaction using web3 instance
    window.web3.eth.sendTransaction({
        from: 'YOUR_WALLET_ADDRESS',
        to: 'RECEIVER_ADDRESS',
        value: '1000000000000000'
    })
    .on('transactionHash', function(hash){
        ...
    })
    .on('receipt', function(receipt){
        ...
    })
    .on('confirmation', function(confirmationNumber, receipt){ ... })
    .on('error', console.error);
}

For detail on using window.web3, please follow web3 document

Using MetaMask

Note: this is available only after Galaxias hardfork

If you're not familiar with adding custom network to MetaMask, please read this article.

Network parameters:

For detail on connecting to MetaMask, please follow this document.

Last updated