KardiaChain JS SDK
  • Overview
  • Getting Started
  • Guides
    • Connecting to KardiaChain
      • Front-end
      • Back-end
    • Working with wallet
    • Sending your first transaction
    • Smart Contract: decentralize application
    • KRC20 tokens
    • KAI Chain module
    • Utilities
  • Reference
    • KardiaClient
    • Account
    • Transaction
    • KAI Chain
    • Smart contract
    • KRC20
    • Objects reference
Powered by GitBook
On this page
  • Using the SDK
  • Using Web3

Was this helpful?

  1. Guides
  2. Connecting to KardiaChain

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)
);

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);
PreviousFront-endNextWorking with wallet

Last updated 3 years ago

Was this helpful?

For detail on using kardiaClient object, please refer to

For detail on using web3, please

KardiaClient
MetaMask document