web3.js中怎么實現(xiàn)跨鏈調(diào)用SimpleChain

今天就跟大家聊聊有關(guān)web3.js中怎么實現(xiàn)跨鏈調(diào)用SimpleChain,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

創(chuàng)新互聯(lián)建站是一家專業(yè)提供永靖企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、H5頁面制作、小程序制作等業(yè)務(wù)。10年已為永靖眾多企業(yè)、政府機構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進行中。

查看RPC接口

首先我們需要熟悉Simplechain的跨鏈 接口,熟悉了接口以后我們就可以直接上手操作。

安裝包文件

首先你需要安裝node環(huán)境,然后使用npm安裝跨鏈包。命令如下:

npm install @sipc/web3

安裝完以后就可以在你的工程項目面集成跨鏈。主要的方法有:getCtxQuery,getCtxOwner,getCtxOwnerByPage,getCtxContent,getCtxContentByPage,ctxGet,ctxGetByNumber, ctxQueryDestValue, getCtxTakerByPage, getCtxStats, getPoolStats

使用示例

npm庫

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 )
})()

看完上述內(nèi)容,你們對web3.js中怎么實現(xiàn)跨鏈調(diào)用SimpleChain有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

網(wǎng)站題目:web3.js中怎么實現(xiàn)跨鏈調(diào)用SimpleChain
地址分享:http://www.muchs.cn/article42/ippjec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、App開發(fā)、外貿(mào)建站、做網(wǎng)站定制網(wǎng)站、動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作