Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to call SimpleChain across chains in web3.js

Shulou Source: shulou.com Published: 2022-06-02 09:39:48 10月04日 Update

Today, I will talk to you about how to implement cross-chain calls to SimpleChain in web3.js. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

View the RPC interface

First of all, we need to be familiar with the cross-link interface of Simplechain. Once we are familiar with the interface, we can get started with it.

Installation package file

First you need to install the node environment, and then use npm to install the cross-link package. The command is as follows:

Npm install @ sipc/web3

After installation, you can integrate cross-chain in your engineering project. The main methods are: getCtxQuery,getCtxOwner,getCtxOwnerByPage,getCtxContent,getCtxContentByPage,ctxGet,ctxGetByNumber, ctxQueryDestValue, getCtxTakerByPage, getCtxStats, getPoolStats.

Use the example

Npm library

Const rpcUrl = "http://192.168.4.104:8546"const Web3 = require ('@ sipc/web3') const web3 = new Web3 (new Web3.providers.HttpProvider (rpcUrl)) (async function () {const blockNumber = await web3.eth.getBlockNumber () const chainId = await web3.cross.net.getId () const owner = await web3.cross.getCtxOwnerByPage ("0x6407d2a4cd26fdd884dc2ed4a4f8882e413d84f6", 2,1) const poolStats = await web3.cross.getPoolStats () const stats = await web3.cross.getCtxStats () for (const item of owner.data ['909']) {console.log (item.txHash)} console.log (blockNumber, chainId, owner, poolStats, stats)} () Do you know more about how to implement cross-chain calls to SimpleChain in web3.js? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Content interfaces commands projects documents methods more environment knowledge examples articles industry information information channels projects channels one support related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno Microsoft Redmi macOS