Back-end

Using the SDK

Initialize the SDK

import KardiaClient from 'kardia-js-sdk';

const kardiaClient = new KardiaClient({ 
    endpoint: 'https://rpc.kardiachain.io' 
});

// Sign and send a transaction
const txPayload = {
  to: 'RECEIVER_WALLET_ADDRESS',
  from: 'YOUR_WALLET_ADDRESS',
  value: 231095,    // Amount of KAI to send
}

const txResult = await transactionModule.sendTransaction(
  txPayload,
  'YOUR_WALLET_PRIVATEKEY',
  true,    // Flag to indicate if you want to wait for the transaction to complete
  50000    // Time (in ms) you want to wait for transaction to complete, default will be 300000 (300s)
);

For detail on using kardiaClient object, please refer to KardiaClient

Using Web3

Note: this is available only after Galaxias hardfork

Initialize web3 instance

import Web3 from 'web3';

const web3 = new Web3('https://rpc.kardiachain.io');

// Sign and send a transaction
const signedTx = await web3.eth.accounts.signTransaction({
    to: 'RECEIVER_WALLET_ADDRESS',
    from: 'YOUR_WALLET_ADDRESS',
    value: '1000000000',
    gas: 2000000,
    chainId: 24 // KardiaChain Mainnet chain id
}, 'YOUR_WALLET_PRIVATEKEY')

const txHash = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);

For detail on using web3, please MetaMask document

Last updated