使用工具:remix、vscode、ganache、ethers.js、metamask、nodejs、solidity語(yǔ)言、?網(wǎng)頁(yè)控制臺(tái)、終端命令行
web3開(kāi)發(fā):前端開(kāi)發(fā) ethers.js
web3開(kāi)發(fā):前端使用ethers.js調(diào)用Hello智能合約。
hello.sol 智能合約文件:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-782399.html
// SPDX-License-Identifier: MIT pragma solidity 0.8.0; contract Hello { function greet() external pure returns(string memory) { return "Hello web3"; } }
dapp.html? 前端文件:文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-782399.html
<html> <head> <script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js" type="text/javascript"></script> <script src="./contract.js" type="text/javascript"></script> </head> <body> <div style="text-align:center"> <div style="text-align: center; margin-top: 30px;"> <button οnclick="connectWallet()">Connect Wallet</button> <button οnclick="runContr
到了這里,關(guān)于智能合約入門開(kāi)發(fā)實(shí)例的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!