blockchain programming

Basics of blockchain programming


I will try to teach you some basic concepts around blockchain programming through this post.

You can access programmatically to a blockchain with many languages, such as Solidity for coding and deploying smart contracts, Javascript/NodeJS for accessing remote functions on deployed smart contracts etc...

Here we will focus on basic concepts, such as those needed for accessing remote functions on existing smart contracts on a blockchain.

For accessing the Binance Smart Chain, we need a remote JSON-RPC endpoint such as https://bsc-dataseed1.binance.org:443

With NodeJS, the way to declare the remote JSON-RPC endpoint for the BSC is the following :

const Web3 = require('web3')
const web3 = new Web3('https://bsc-dataseed1.binance.org:443')

You can then, if you need, create a new wallet with the following code :

const account = web3.eth.accounts.create()

Or you can access an existing wallet thanks to the following code :

const privateKey = "myprivatekey"
const account = web3.eth.accounts.privateKeyToAccount(privateKey)

You will have to change the privateKey variable to an existing private key.

That's all for now ! 

 

How do you rate this article?

7


Blockchain French Tech
Blockchain French Tech

Software engineer, Blockchains (Ethereum, BSC...), Solidity (ERC20, BEP20...).


Cryptocurrency trading bots
Cryptocurrency trading bots

Informations about the use of cryptocurrency trading bots.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.