KOISAN INTERNATIONAL COIN (KIC)
  • 📜KOISAN INTERNATIONAL COIN (KIC) WHITEPAPER
  • ⛓️KOISAN CHAIN
    • About Koisan Chain
    • Wallet
    • Consensus
    • Meta Transaction
    • Genesis File
    • Node
      • Compile and Run
      • Deployment
      • On-Chain Interaction
      • Contract
      • Private Chain Construction
      • Graph Node
      • Mainnet
      • DApp-Governance
      • Txpool
    • DApp Development
      • Account Management
      • KIC20
      • NFT
      • Remix
      • Truffle
  • 👥KOISAN TEAM
  • 📡KIC ECOSYSTEM
    • 🦈KOISAN WORLD NFT GAME
    • 🎮Gameplay
  • 🌐KOISAN SOCIAL MEDIA
Powered by GitBook
On this page
  • RPC
  • SDK
  • Get chain info
  • Generate Account
  • Built Transaction
  1. KOISAN CHAIN
  2. Node

On-Chain Interaction

Koisan is compatible with Ethereum's ecosystem,support all Ethereum's RPC API and DK.

PreviousDeploymentNextContract

Last updated 3 years ago

RPC

Example:

curl -s -H 'content-type:application/json' -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://localhost:8545

SDK

Use Ethereum SDK library such as web3j,web3js, etc for development.

Get chain info

const Web3 = require('web3')

async function getChainId() {
    const web3 = new Web3('https://rpc.koisan-chain.com')
    let chainId = await web3.eth.getChainId()
    console.log(`chain id: ${chainId}`)
    return chainId
}

Generate Account

const Web3Accounts = require('web3-eth-accounts')

let account = new Web3Accounts().create()
//do not do this on prd env
console.log(`account generated. address: ${account.address}, private key: ${account.privateKey}`)

Built Transaction

const Web3 = require('web3')

async function transfer(fromAccount, to, value){
    const web3 = new Web3('https://rpc.koisan-chain.com')
    let chainId = await web3.eth.getChainId()
    let nonce = await web3.eth.getTransactionCount(fromAccount.address)
    let gasPrice = await web3.eth.getGasPrice()

    let unsigned = {
        from: fromAccount.address,
        to,
        value: web3.utils.numberToHex(web3.utils.toWei(value, 'ether')),
        gasPrice,
        nonce,
        chainId,
    }

    unsigned.gas = await web3.eth.estimateGas(unsigned)

    let signed = await fromAccount.signTransaction(unsigned)
    return signed
}

⛓️
RPC Method List