web3.js
Web3.py and Web3.js are a set of libraries that facilitate the interaction of developers with Conflux nodes via the HTTP, IPC, or WebSocket communication protocols, using the Python and JavaScript programming languages respectively. This guide will provide you with the expertise to leverage the Web3.js library for transmitting transactions and deploying smart contracts.
Initiate a Project
To start, first create a directory where all the relevant files generated throughout this guide can be stored. Execute this task with the following command:
mkdir web3-examples && cd web3-examples
For the successful implementation of the upcoming sections, you'll need to install the Web3 library and the Solidity compiler. To obtain both packages, execute the following command:
npm install web3 solc@0.8.0
Setup the HTTP connection
Prepare your Web3 HTTP connection to align with any evm-powered network. To synchronize your project, you must secure an endpoint and API key of your own.
Here's how you can get started:
// Create a Web3 instance:
const Web3 = require('web3');
// Insert your RPC URL to establish an HTTP connection to your RPC endpoint:
const web3 = new Web3('RPC-API-ENDPOINT-HERE');