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

常州网站seo网站重新制作多久google重新收录

常州网站seo,网站重新制作多久google重新收录,郑州网站设计制作哪家好,全网营销推广怎么收费题记 用Web3实现前端与智能合约的交互#xff0c;以下是操作流程和代码。 准备ganache环境 文章地址#xff1a;4.DApp-MetaMask怎么连接本地Ganache-CSDN博客 准备智能合约 文章地址#xff1a; 2.DApp-编写和运行solidity智能合约-CSDN博客 编写index.html文件 !…题记 用Web3实现前端与智能合约的交互以下是操作流程和代码。 准备ganache环境 文章地址4.DApp-MetaMask怎么连接本地Ganache-CSDN博客  准备智能合约  文章地址 2.DApp-编写和运行solidity智能合约-CSDN博客 编写index.html文件 !DOCTYPE html html head     titleName Contract Demo/title     !--导入web3库--     script srchttps://cdn.jsdelivr.net/npm/web31.5.2/dist/web3.min.js/script     script     // 检查Metamask是否已安装     if (typeof window.ethereum ! undefined) {     console.log(Metamask已安装);     }     // 设置Web3.js提供者为Metamask     const provider window.ethereum;     const web3 new Web3(provider);     // 请求Metamask连接到以太坊网络     provider.request({ method: eth_requestAccounts })     .then(() {       console.log(Metamask已连接到以太坊网络);     })     .catch((err) {       console.error(无法连接到以太坊网络, err);     });     function setName() {     // 合约地址     const contractAddress 0x32FDC4E86421143b1c27dE49542Bc8ECE2B162a0;     // 合约ABI     const contractABI [     {         inputs: [             {                 internalType: string,                 name: _name,                 type: string             }         ],         name: setName,         outputs: [],         stateMutability: nonpayable,         type: function     },     {         inputs: [],         name: getName,         outputs: [             {                 internalType: string,                 name: ,                 type: string             }         ],         stateMutability: view,         type: function     }     ];     const contract new web3.eth.Contract(contractABI, contractAddress);     const name document.getElementById(name).value;     // 替换为您的账户地址web3.eth.defaultAccount     const fromAddress 0x4e8eB4d1C203929074A3372F3703E556820fEA57;     //contract.methods.setName(name).send({from: fromAddress})     contract.methods.setName(name).send({from: fromAddress})     .on(transactionHash, function(hash){         console.log(Transaction Hash:, hash);     })     .on(receipt, function(receipt){         console.log(Transaction Receipt:, receipt);     })     .on(error, function(error){         console.error(Error:, error);     });     }     function getName() {     // 合约地址     const contractAddress 0x32FDC4E86421143b1c27dE49542Bc8ECE2B162a0;     // 合约ABI     const contractABI [     {         inputs: [             {                 internalType: string,                 name: _name,                 type: string             }         ],         name: setName,         outputs: [],         stateMutability: nonpayable,         type: function     },     {         inputs: [],         name: getName,         outputs: [             {                 internalType: string,                 name: ,                 type: string             }         ],         stateMutability: view,         type: function     }     ];     const contract new web3.eth.Contract(contractABI, contractAddress);     contract.methods.getName().call()     .then(function(result) {         console.log(Name:, result);         document.getElementById(nameValue).innerText result;     })     .catch(function(error) {         console.error(Error:, error);     });     }     /script /head body     h1设置姓名/h1     label forname姓名:/label     input typetext idname     button οnclicksetName()设置姓名/button     br     button οnclickgetName()得到姓名/button     br     span idnameValue/span /body /html !DOCTYPE html html headtitleName Contract Demo/title!--导入web3库--script srchttps://cdn.jsdelivr.net/npm/web31.5.2/dist/web3.min.js/scriptscript// 检查Metamask是否已安装if (typeof window.ethereum ! undefined) {console.log(Metamask已安装);}// 设置Web3.js提供者为Metamaskconst provider window.ethereum;const web3 new Web3(provider);// 请求Metamask连接到以太坊网络provider.request({ method: eth_requestAccounts }).then(() {console.log(Metamask已连接到以太坊网络);}).catch((err) {console.error(无法连接到以太坊网络, err);});function setName() {// 合约地址const contractAddress 0x32FDC4E86421143b1c27dE49542Bc8ECE2B162a0; // 合约ABIconst contractABI [{inputs: [{internalType: string,name: _name,type: string}],name: setName,outputs: [],stateMutability: nonpayable,type: function},{inputs: [],name: getName,outputs: [{internalType: string,name: ,type: string}],stateMutability: view,type: function}]; const contract new web3.eth.Contract(contractABI, contractAddress);const name document.getElementById(name).value;// 替换为您的账户地址web3.eth.defaultAccountconst fromAddress 0x4e8eB4d1C203929074A3372F3703E556820fEA57; //contract.methods.setName(name).send({from: fromAddress})contract.methods.setName(name).send({from: fromAddress}).on(transactionHash, function(hash){console.log(Transaction Hash:, hash);}).on(receipt, function(receipt){console.log(Transaction Receipt:, receipt);}).on(error, function(error){console.error(Error:, error);});}function getName() {// 合约地址const contractAddress 0x32FDC4E86421143b1c27dE49542Bc8ECE2B162a0; // 合约ABIconst contractABI [{inputs: [{internalType: string,name: _name,type: string}],name: setName,outputs: [],stateMutability: nonpayable,type: function},{inputs: [],name: getName,outputs: [{internalType: string,name: ,type: string}],stateMutability: view,type: function}]; const contract new web3.eth.Contract(contractABI, contractAddress);contract.methods.getName().call().then(function(result) {console.log(Name:, result);document.getElementById(nameValue).innerText result;}).catch(function(error) {console.error(Error:, error);});}/script /head bodyh1设置姓名/h1label forname姓名:/labelinput typetext idnamebutton onclicksetName()设置姓名/buttonbrbutton onclickgetName()得到姓名/buttonbrspan idnameValue/span /body /html执行程序  使用vscode的Live Server打开网页 参考这篇文章的执行方法1.Vue-在独立页面实现Vue的增删改查-CSDN博客  展示图  发起交易  完成交易  后记 觉得有用可以点赞或收藏
http://www.sadfv.cn/news/243890/

相关文章:

  • 绥中做网站公司路飞和女帝做h的网站
  • 做服装外单的网站韩国seocaso
  • 手机上怎么做网站创业买网站送域名
  • 京东电子商务网站的建设网站更换服务器教程
  • 网站建设要经历哪些步骤?seo关键词排名优化费用
  • 云服务器 网站建设学校网站的报告
  • 技术支持保定网站建设 定兴网站开发书籍
  • 怎么在58建设企业的网站台州云推广网站
  • 国内网站空间主机辽宁大连最新消息今天
  • 无为网站设计iis7.5部署网站
  • 常州网站建设公司排名专业网页设计师
  • 如何上传网站到空间淄博网站建设yx718
  • 来宾住房和城乡建设网站广告联盟赚钱app
  • 郑州陆港开发建设有限公司网站wordpress每篇文章加水印
  • 网站的用途企业信息管理系统实训报告
  • 网站的首页标题在哪里设置的山东省建设管理信息网站
  • 做网站用那一种语言最好域名价格一览表
  • 网站托管团队iis5.1建网站
  • 宁波网站推广软件服务如何用ps做网站
  • 刚成立公司如何做网站手机商城源码
  • 河南微网站开发怎么做网站公司宣传资料
  • .net手机网站源码南京网站建设包括哪些
  • 邹平做网站的公司有哪些网页设计素材网站花
  • 湖南网站制作外包wordpress浮动音乐
  • 建设网站需要哪些东西外贸网站 模板
  • 做网站网页需要什么技术网站在百度上搜索不到
  • 海外音乐类网站做的比较好的互联网如何挣钱创业
  • 图片交易网站如何建设网站建设与维护 许宝良 课件
  • 淘宝内部优惠券网站建设网络直播网站建设
  • 作文网下载windows优化大师的作用