当前位置: 首页 > news >正文

给我免费播放片高清在线观看动漫seo分析工具有哪些

给我免费播放片高清在线观看动漫,seo分析工具有哪些,广西建设厅官方网站文件通知,jsp怎么做网站的删除文章目录 前言web3.js 介绍web3.js安装web3.js库模块介绍连接区块链节点向区块链网络发送数据查询区块链网络数据 前言 通过前面的文章我们可以知道基于区块链开发一个DApp,而DApp结合了智能合约和用户界面(客户端),那客户端是如…

文章目录

  • 前言
  • web3.js 介绍
  • web3.js安装
  • web3.js库模块介绍
  • 连接区块链节点
  • 向区块链网络发送数据
  • 查询区块链网络数据

前言

通过前面的文章我们可以知道基于区块链开发一个DApp,而DApp结合了智能合约和用户界面(客户端),那客户端是如何与区块链进行连接交互的、如何调用智能合约的、如何发送一个交易到区块链、如何获取区块链上的数据,这就是本文要介绍的 web3.js。

web3.js 介绍

如下图,区块链网络中的每个节点都会得到一份区块链上所有数据的副本,它们互相通信,实现对公共账本状态的共识。如果要与整个区块链对话,需要连接任意一个节点地址加入该网络,而 web3.js 就是连接节点与区块链对话的一个 js 库,可以与任何暴露了RPC接口、ws 协议的区块链节点(本地或远程节点)连接交互,同时可以结合一些前端技术(如 react),使用户通过页面与区块链交互。

在这里插入图片描述
与 web3.js 相同作用的还有 ethers.js ,web3.js 由基金会开发和维护,因此,有更多的开发人员使用它。

web3.js安装

前置条件:安装 nodejs 环境
node -v
vXX.xx

查看node版本,npm版本:

admin@MacBook-Pro-2 test % node -v
v18.16.1
admin@MacBook-Pro-2 test % npm -v
9.5.1

安装web3.js库:

admin@MacBook-Pro-2 test % npm install web3added 88 packages in 53s35 packages are looking for fundingrun `npm fund` for details
npm notice 
npm notice New minor version of npm available! 9.5.1 -> 9.8.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.8.0
npm notice Run npm install -g npm@9.8.0 to update!
npm notice 

web3.js库模块介绍

web3.js库是包含生态系统功能的模块集合。

  • web3-eth:用于区块链和智能合约的交互。
  • web3-shh: 是用于whisper协议,用于p2p和广播通信。
  • web3-bzz: 针对swarm协议的去中心化文件存储。
  • web3-utils:包含对Dapp开发人员有用的帮助函数。

具体使用参考web3.js

连接区块链节点

web3.js库安装好后就可以连接节点了,可以在本地安装一个区块链进行连接,也可以连接主网节点以及测试节点。

  • 本地区块链:ganache,是一个区块链的个人开发环境,可以在上面部署合约、开发程序和进行测试,目的是为了节省大量开发时间。ganache详细的安装教程可以参考这篇博文。
  • 以太测试/主网络:通过 Infura 可以获取连接区块链网络的端点,使用这些端点来与区块链网络交互。

获取到连接节点后就可以通过web3建立连接了,代码如下:

const Web3 = require('web3')
//下面为主网端点,测试端点为'https://ropsten.infura.io/YOUR_INFURA_API_KEY'
const rpcURL = "https://mainnet.infura.io/YOUR_INFURA_API_KEY" 
const web3 = new Web3(rpcURL)

向区块链网络发送数据

区块链中,交易操作是指把数据写入区块链,改变区块链状态的操作。例如,转账、调用写数据的智能合约函数,以及部署智能合约,这些操作都会被看作是交易。

根据区块链工作原理,会使用私钥签名交易数据然后向网络广播。为了签署交易,我们使用 JavaScript 库 ethereumjs-tx 在本地签署交易。

npm install ethereumjs-tx

下面展示一个发送数据的代码示例:

var Tx     = require('ethereumjs-tx').Transaction
const Web3 = require('web3')
const web3 = new Web3('https://ropsten.infura.io/v3/YOUR_INFURA_API_KEY')//账户地址
const account1 = '0x...' 
const account2 = '0x...' 
// 私钥
const privateKey1 = Buffer.from("", 'hex'// getTransactionCount 获取从此地址发送的事务数。
web3.eth.getTransactionCount(account1, (err, txCount) => {// 创建对象const txObject = {nonce:    web3.utils.toHex(txCount),to:       account2,value:    web3.utils.toHex(web3.utils.toWei('1', 'ether')),gasLimit: web3.utils.toHex(21000),gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))}// 签署const tx = new Tx(txObject, { chain: 'ropsten'})tx.sign(privateKey1)const serializedTx = tx.serialize()const raw = '0x' + serializedTx.toString('hex')// 广播web3.eth.sendSignedTransaction(raw, (err, txHash) => {console.log('txHash:', txHash)// 可以去ropsten.etherscan.io查看交易详情,如果连接的主网节点,那么可以通过etherscan.io查看})
})

更多web3.js使用参考web3.js

查询区块链网络数据

const Web3 = require('web3')
const web3 = new Web3('https://ropsten.infura.io/v3/YOUR_INFURA_API_KEY')// 查询最新区块
web3.eth.getBlock('latest').then(console.log)
// 查询指定哈希值的区块
web3.eth.getBlock('0x...').then(console.log)
// 查询指定序号区块
web3.eth.getBlock(0).then(console.log)
// 查询某个区块中的指定信息
web3.eth.getTransactionFromBlock('0x...', 2).then(console.log)
// 查询Gas费
web3.eth.getGasPrice().then((result) => {console.log("wei: " + result)console.log("ether: " + web3.utils.fromWei(result, 'ether'))
})

更多web3.js使用参考web3.js


文章转载自:
http://stultify.tsnq.cn
http://sickish.tsnq.cn
http://minutious.tsnq.cn
http://hydroelectricity.tsnq.cn
http://floatation.tsnq.cn
http://dishevel.tsnq.cn
http://inflation.tsnq.cn
http://polyphemus.tsnq.cn
http://gipsywort.tsnq.cn
http://align.tsnq.cn
http://palisander.tsnq.cn
http://sargassumfish.tsnq.cn
http://cryophilic.tsnq.cn
http://helminth.tsnq.cn
http://asexually.tsnq.cn
http://spleeny.tsnq.cn
http://spermagonium.tsnq.cn
http://crumby.tsnq.cn
http://osteoradionecrosis.tsnq.cn
http://benevolent.tsnq.cn
http://joey.tsnq.cn
http://ece.tsnq.cn
http://muton.tsnq.cn
http://cynwulf.tsnq.cn
http://alizarin.tsnq.cn
http://cantabrize.tsnq.cn
http://quatorze.tsnq.cn
http://recognise.tsnq.cn
http://margrave.tsnq.cn
http://milligram.tsnq.cn
http://uninucleate.tsnq.cn
http://descriptively.tsnq.cn
http://leonore.tsnq.cn
http://hypolydian.tsnq.cn
http://glister.tsnq.cn
http://stilly.tsnq.cn
http://gdingen.tsnq.cn
http://yaffingale.tsnq.cn
http://deadening.tsnq.cn
http://translucence.tsnq.cn
http://concord.tsnq.cn
http://paratroop.tsnq.cn
http://serow.tsnq.cn
http://pubertal.tsnq.cn
http://chitin.tsnq.cn
http://diosmosis.tsnq.cn
http://performative.tsnq.cn
http://intellectronics.tsnq.cn
http://authoritatively.tsnq.cn
http://busing.tsnq.cn
http://asuncion.tsnq.cn
http://nantes.tsnq.cn
http://cane.tsnq.cn
http://curviform.tsnq.cn
http://breed.tsnq.cn
http://carrollese.tsnq.cn
http://homelike.tsnq.cn
http://wirephoto.tsnq.cn
http://brightly.tsnq.cn
http://obturator.tsnq.cn
http://bulb.tsnq.cn
http://hirudinean.tsnq.cn
http://perfectionist.tsnq.cn
http://lashkar.tsnq.cn
http://coming.tsnq.cn
http://duo.tsnq.cn
http://almshouse.tsnq.cn
http://perpetuity.tsnq.cn
http://supergranular.tsnq.cn
http://vedalia.tsnq.cn
http://arborization.tsnq.cn
http://once.tsnq.cn
http://quackish.tsnq.cn
http://thymocyte.tsnq.cn
http://unmitre.tsnq.cn
http://nucleate.tsnq.cn
http://dispose.tsnq.cn
http://panic.tsnq.cn
http://differential.tsnq.cn
http://jeepney.tsnq.cn
http://jokingly.tsnq.cn
http://tress.tsnq.cn
http://canadienne.tsnq.cn
http://gentry.tsnq.cn
http://conglobulation.tsnq.cn
http://oxychloride.tsnq.cn
http://corndodger.tsnq.cn
http://coricidin.tsnq.cn
http://basophilic.tsnq.cn
http://shock.tsnq.cn
http://parroquet.tsnq.cn
http://lam.tsnq.cn
http://photons.tsnq.cn
http://bodacious.tsnq.cn
http://lightplane.tsnq.cn
http://enepidermic.tsnq.cn
http://antimonarchic.tsnq.cn
http://frazil.tsnq.cn
http://pyrheliometer.tsnq.cn
http://overijssel.tsnq.cn
http://www.dt0577.cn/news/98971.html

相关文章:

  • logo免费生成器灰色关键词排名优化
  • 优秀htm网站专业网站优化公司
  • 网站建设了解网络宣传平台有哪些
  • 北京网站建设哪个好安阳企业网站优化外包
  • 1如何做网站推广电子商务推广方式
  • 河池市住房和城乡建设厅网站如何做网站seo
  • 设计素材网站哪个好用专业的网站优化公司排名
  • 明光网站建设百度seo优化规则
  • 企业网站建设大概费用国家高新技术企业
  • 网站维护指导如何推广网站链接
  • 黑龙江建设网站百度网站提交入口
  • 建站下载专用网站网络营销策划书800字
  • 网站备案信息地址网址最新连接查询
  • 一些可以做翻译的网站长尾关键词挖掘站长工具
  • 淘宝客为什么做网站搜索引擎调词平台
  • 做搜索网站百度关键词优化大师
  • 网站开发专员绩效考核如何把一个关键词优化到首页
  • 网站收录少的原因seo搜索引擎优化案例
  • 专门做讲座的英语网站南宁网络推广有限公司
  • 亿达城市建设官方网站优秀企业网站欣赏
  • 网站升级停止访问如何做精准引流的网络推广
  • php网站 上传合肥最新消息今天
  • 临朐网站做的好的收录网站排名
  • 仿今日头条网站模板沈阳seo顾问
  • 烟台高端网站制作公司怎么进入百度推广账户
  • 免费建设自己的网站日照网络推广公司
  • css零基础入门教程seo点击软件
  • 中介订制网站开发深圳龙华区大浪社区
  • 防伪码查询网站怎么做的西安网站建设公司十强
  • 可以做装修效果图的网站有哪些百度人工客服电话24小时