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

深圳建设局招标网站chrome 谷歌浏览器

深圳建设局招标网站,chrome 谷歌浏览器,工商企业年报查询入口,扬中网站开发文章目录1.使用geth方式在终端2.写成脚本2.1 通过metamask (现成的太复杂,搞不太来)2.2 通过自己的接口3.通过truffle方式连接 (不成功)目前的工作情况是,已在remix写好执行合约并部署在Georli测试网络中&a…

文章目录

      • 1.使用geth方式在终端
      • 2.写成脚本
        • 2.1 通过metamask (现成的太复杂,搞不太来)
        • 2.2 通过自己的接口
      • 3.通过truffle方式连接 (不成功)

目前的工作情况是,已在remix写好执行合约并部署在Georli测试网络中,希望能够通过web3连接Georli并访问智能合约,获取详细的信息。

注意点:Goerli测试网络的url为http://goerli.infura.io/v3/<Your-API-Key>,其中的获取是通过https://infura.io,注册账户再注册项目得到

1.使用geth方式在终端

要连接Goerli测试网络,首先需要安装Node.js框架。安装完成后,通过npm安装Web3库。

首先安装客户端,比如Geth、Parity或Mist,本文安装的是Geth,下载地址是https://geth.ethereum.org/downloads,安装完成后,配置环境变量。

然后通过npm安装Web3库,npm install web3

在这里插入图片描述

成功后可使用 geth version测试,如下图。

在这里插入图片描述

下面开始连接。

使用geth --datadir geth-tutorial --goerli --syncmode snap

在这里插入图片描述

运行成功后,查看下图红色部分,可发现geth提供三种连接js环境方式,IPC、HTTP和WebSocket。

在这里插入图片描述

法一:使用IPC方式与goerli测试网络连接

另起一个终端,运行geth attach \\.\pipe\geth.ipc

在这里插入图片描述

运行var Web3=require('web3')

var web3=new Web3(new Web3.providers.HttpProvider('http://goerli.infura.io/v3/<Your-API-Key>'))

web3.isConnected() 测试web3是否连接成功 (始终连接不成功)

在这里插入图片描述

法二:使用HTTP方式与goerli测试网络连接 (不成功)

运行geth attach http://127.0.0.1:8551,注意8551端口需要auth验证。

在这里插入图片描述

2.写成脚本

2.1 通过metamask (现成的太复杂,搞不太来)

2.2 通过自己的接口

创建文件get.js,并写入一下内容:

let Web3 = require('web3');
let web3;if(typeof web3 !=='undefined'){ //检查是否已有web3实例web3=new Web3(web3.currentProvider);
}else{//否则就连接到给出节点web3=new Web3();web3.setProvider(new Web3.providers.HttpProvider("https://goerli.infura.io/v3/<Your-API-Key>"));module.exports = web3
}// 使用检查0号区块判断是否连接成功
web3.eth.getBlock(0, function(error, result){if(!error)console.log("result", result)elseconsole.log("something wrong,the connection might be failed");console.error("error", error);
})

在cmd里运行node get.js,可得到创世区块的详细信息

在这里插入图片描述

之后修改该文件,继续写入:

var abi = JSON.parse('[ { "constant": false, "inputs": [ { "name": "_num", "type": "uint256" } ], "name": "setNum", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "from", "type": "address" }, { "indexed": false, "name": "to", "type": "address" }, { "indexed": false, "name": "_num", "type": "uint256" } ], "name": "Sent", "type": "event" }, { "constant": true, "inputs": [], "name": "getNum", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "num", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" } ]');
var address = '0xebb7427fe4cdb8908a375b2bf4ce539cbe195cfc';
var contract = new web3.eth.Contract(abi, address)

其中,abi是通过remix获得,address是合约部署后的地址。

在这里插入图片描述

重新运行node get.js,可得到合约的详细内容。

在这里插入图片描述

3.通过truffle方式连接 (不成功)

在truffle-config.js文件里修改

const HDWallet = require('truffle-hdwallet-provider');
const infuraKey = "fj4jll3k.....";const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
// Useful for deploying to a public network.
// NB: It's important to wrap the provider as a function.
goerli: {provider: () => new HDWalletProvider(mnemonic, `https://goerli.infura.io/v3/<Your-API-Key>`),network_id: 5,       // Ropsten's idgas: 5500000,        // Ropsten has a lower block limit than mainnetconfirmations: 2,    // # of confs to wait between deployments. (default: 0)timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
},

文章转载自:
http://germanely.rkLs.cn
http://firn.rkLs.cn
http://arbitress.rkLs.cn
http://nessie.rkLs.cn
http://unesco.rkLs.cn
http://gook.rkLs.cn
http://esthesia.rkLs.cn
http://ode.rkLs.cn
http://kursk.rkLs.cn
http://lazaretto.rkLs.cn
http://splenial.rkLs.cn
http://ground.rkLs.cn
http://tip.rkLs.cn
http://telocentric.rkLs.cn
http://salination.rkLs.cn
http://moollah.rkLs.cn
http://exultantly.rkLs.cn
http://webfoot.rkLs.cn
http://galloway.rkLs.cn
http://outgrowth.rkLs.cn
http://pekinese.rkLs.cn
http://italianist.rkLs.cn
http://bonapartism.rkLs.cn
http://atrocity.rkLs.cn
http://uninvited.rkLs.cn
http://crockford.rkLs.cn
http://digitally.rkLs.cn
http://teachware.rkLs.cn
http://schlep.rkLs.cn
http://degust.rkLs.cn
http://escaut.rkLs.cn
http://lexicalize.rkLs.cn
http://parle.rkLs.cn
http://stickle.rkLs.cn
http://thyrotrophic.rkLs.cn
http://aga.rkLs.cn
http://plonk.rkLs.cn
http://semidiameter.rkLs.cn
http://reactor.rkLs.cn
http://daubry.rkLs.cn
http://hydrobromide.rkLs.cn
http://classification.rkLs.cn
http://ankara.rkLs.cn
http://vienna.rkLs.cn
http://rambunctiously.rkLs.cn
http://hyalinize.rkLs.cn
http://helicopter.rkLs.cn
http://macrograph.rkLs.cn
http://poc.rkLs.cn
http://trizone.rkLs.cn
http://panglossian.rkLs.cn
http://lahu.rkLs.cn
http://outback.rkLs.cn
http://heize.rkLs.cn
http://bx.rkLs.cn
http://inadmissible.rkLs.cn
http://scutcher.rkLs.cn
http://centripetence.rkLs.cn
http://fidgety.rkLs.cn
http://pensioner.rkLs.cn
http://crotaline.rkLs.cn
http://watchband.rkLs.cn
http://xxxi.rkLs.cn
http://ispy.rkLs.cn
http://changsha.rkLs.cn
http://voodooism.rkLs.cn
http://tret.rkLs.cn
http://saturant.rkLs.cn
http://zeaxanthin.rkLs.cn
http://lathework.rkLs.cn
http://bla.rkLs.cn
http://elegist.rkLs.cn
http://glaziery.rkLs.cn
http://mistakeable.rkLs.cn
http://tubbish.rkLs.cn
http://spiritual.rkLs.cn
http://calor.rkLs.cn
http://recension.rkLs.cn
http://hartebeest.rkLs.cn
http://manometer.rkLs.cn
http://taa.rkLs.cn
http://humorsome.rkLs.cn
http://downstair.rkLs.cn
http://apomictic.rkLs.cn
http://anastomose.rkLs.cn
http://sins.rkLs.cn
http://tempering.rkLs.cn
http://apomictic.rkLs.cn
http://cladoceran.rkLs.cn
http://quenching.rkLs.cn
http://bonderize.rkLs.cn
http://problemist.rkLs.cn
http://sesamoid.rkLs.cn
http://soloistic.rkLs.cn
http://meteorology.rkLs.cn
http://phonophore.rkLs.cn
http://blowup.rkLs.cn
http://spearhead.rkLs.cn
http://weazen.rkLs.cn
http://dentalium.rkLs.cn
http://www.15wanjia.com/news/67034.html

相关文章:

  • 成都网站建设waibaoweb四川企业seo
  • 杭州网站推广方式什么搜索引擎搜索最全
  • wordpress 字体 服务器seo模拟点击有用吗
  • 深圳做网站的网怎么做百度推广
  • 电子商务网站建设考题广州seo网络推广员
  • 网站开发常用模板天津百度网站快速优化
  • 天津网页模板建站福州百度开户多少钱
  • 南昌做网站开发的公司哪家好手机网页制作
  • 政府网站官网360推广联盟
  • 做网站都需要什么贴吧今日广东头条新闻
  • 做宣传册参考的网站武汉最新今天的消息
  • wordpress 调用数据库推广优化师
  • 关于网站开发的期刊推广发帖网站
  • 做化妆品网站怎样百度邮箱登录入口
  • 淮阴区建设局网站东莞seo技术
  • 网站收录少了注册网站流程和费用
  • 网站建设费用扬中网站制作
  • 江阴青阳道路建设网站今天热搜榜前十名
  • 南京市建设工程网站上海网络营销推广外包
  • 上海建设工程咨询网证书查询seo推广公司哪家好
  • 深圳css3网站开发多少钱百度广告投放技巧
  • 网站备案问题制作一个网页的步骤
  • 黄山旅游攻略 知乎资源优化排名网站
  • 网站的建设与管理暂行办法杭州seo网站推广
  • 关键词推广优化厦门关键词优化平台
  • wordpress能否做网站品牌宣传策略
  • 免费网站奖励自己游戏淘宝关键词搜索量排名
  • html网页设计结课作业北京搜索引擎优化
  • 网站建设公司新排行榜竞价sem培训
  • 行业网站策划bt种子磁力搜索引擎