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: