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
  • Create instances of web3
  • Javascript
  • Python3
  • Create an Account
  • Javascript
  • Python3
  • Recover Account Via Private Key
  • Javascript
  • Python3
  1. KOISAN CHAIN
  2. DApp Development

Account Management

Wallet Account Management

PreviousDApp DevelopmentNextKIC20

Last updated 3 years ago

Some interfaces that interact with the chain have been encapsulated by web3 to facilitate our DApp development. Via theses web3 encapsulated interfaces, we can use different languages to interact with KIC. This article elaborates on how to use JavaScript and Python to manage accounts on KIC through Web3.

Create instances of web3

Javascript

Mostly, javascript uses database to interact with KIC.

  • Connect to Mainnet

const w3 = new Web3("https://rpc.koisan-chain");
  • Connect to Testnet

const w3 = new Web3("https://testnet-rpc.koisan-chain");

Python3

Mostly, python uses packageto interact with KIC.

  • Connect to Mainnet

from web3 import Web3
from web3.middleware import geth_poa_middleware
provider = Web3.HTTPProvider("https://rpc.koisan-chain")
w3 = Web3(provider)
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
  • Connect to Testnet

from web3 import Web3
from web3.middleware import geth_poa_middleware
provider = Web3.HTTPProvider("https://testnet-rpc.koisan-chain")
w3 = Web3(provider)
w3.middleware_onion.inject(geth_poa_middleware, layer=0)

Create an Account

After instantiating web3, you can return a random account with the following call:

Javascript

const account = w3.eth.accounts.create();
// print account
console.log(account);
/*
example:
{
  address: '0x00DE048c92eF8D6FeC6275E1907E38798808005d',
  privateKey: '0xc2a58a08abcd566348a6d2798b0b074fc8b7b66a650a7aaf463e6d36b4b9776e',
  signTransaction: [Function: signTransaction],
  sign: [Function: sign],
  encrypt: [Function: encrypt]
}
*/

Python3

account = w3.eth.account.create();
# print private key
print(account.privateKey.hex())
# example: `0x9b308e83c8120818a721fc999618d8869da61c0b440386b963523bcb26fe9839'

# print address
print(account.address)
# example: '0xC286d47ABE4C9B8B2F724610B9eb9e91D7a7De9A'

Recover Account Via Private Key

You can also recover your account on KIC directly through web3 if you have access to your private key.

Javascript

const account = w3.eth.accounts.privateKeyToAccount("your private key string")

Python3

account = w3.eth.account.privateKeyToAccount("your private key string")
⛓️
web3.js
Web3.py