Web3.js
Web3.js is a robust and flexible collection of TypeScript and JavaScript libraries that allows developers to interact with Lycan nodes over HTTP, IPC or WebSocket connections.
Check out web3js for installation details and an overview.
Initializing Web3.js with Lycan Chain
Once you have Web3.js installed, you need to set up a Web3 instance and connect it to the Lycan Chain network. Here’s how you can do it:
This code initializes Web3.js and connects it to the Lycan Chain using the provided RPC URL. The defaultCommon
parameter is configured to specify the custom chain details for Lycan Chain.
Interacting with Smart Contracts
Initializing a Contract
To interact with a smart contract on Lycan Chain, you'll need the contract's ABI (Application Binary Interface) and its deployed address. Here’s an example of how to initialize a contract:
Advanced Configuration
Custom Chain Configuration
By setting web3.eth.defaultCommon
, you ensure that Web3.js is aware of the custom chain parameters for Lycan Chain. This is crucial for correctly signing transactions and interacting with the network.
This configuration tells Web3.js to use the specified chain ID and network ID for all interactions, ensuring compatibility with Lycan Chain.
Last updated