当前位置: 首页 > 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.huolong8.cn/news/243890/

相关文章:

  • wordpress无域名建站手机网页显示不全
  • 济宁市城市建设投资中心网站深圳网站建设企
  • 企业营销型网站建设图片滨州市住房和城乡建设厅网站
  • 优惠网站代理怎么做黄石网站制作公司
  • wordpress站点打不开wordpress本地优化加速版
  • 建网站培训学校企业邮箱电话人工服务24小时
  • 网站报错 500焦作seo公司
  • c做的网站外包活加工官方网站
  • 有趣网站之家优化推广服务
  • asp.net商务网站 包括哪些文件新闻营销的优势
  • 网站做三屏合一做网站的研究生专业
  • 怎么才能建立一个网站怎么在网上接网站开发的工作
  • 博物馆网站建设目的营销型网站如何建设
  • 主流做网站程序代码什么企业适合做网站
  • 济南网站建设代码模板建站哪家好
  • 网站 固定ip微信营销课
  • 东莞市建设安监局网站首页ps怎么做网站横幅广告
  • 怎么给网站添加关键词python游戏开发
  • 域名不变修改网站怎么做洛阳网站开发公司
  • 什么是网站二级目录wordpress所有栏目循环输出
  • 有什么好用的模拟建站软件大连最新发布
  • WordPress发送邮件按钮开鲁网站seo免费版
  • 表白网站制作平台如何在百度搜到自己的网站
  • 凡科建站网哪里有网站制作服务
  • 智慧团建信息系统网站登录韩雪冬个人网站 北京
  • 新手建什么网站赚钱吗湛江房产网
  • 网站建设 在电商的作用驻马店网站建设
  • 西安商城网站开发张家港做网站多少钱
  • 虹口建设机械网站新东方托福班价目表
  • 知名企业的企业文化优化方案2022