1. 安装和配置 Setup

  1. 下载Metamask 到Google Chrome

  2. 领取测试币(Ropsten Tesnet):

    Ropsten testnet faucet

  3. 安装node.js

    Node.js

  4. 安装lite-server

npm install -g lite-server

2. 创建网页 Create Website

创建2个文件,index.html, styles.css

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Simple dApp</title>
    <link rel="stylesheet" href="styles.css">
  </head>
  <body>
      <h1>Simple dApp!</h1>
      <label for="storeString">Input Sentences:</label> <br />
      <input type="text" placeholder="Enterstring" id="storeString">
      <center>
        <button class="button-63" role="button" onclick="setStr()">Set String</button>
        <button class="button-63" role="button" onclick="getStr()">Get String</button>
      </center>

  </body>
</html>

<input> 中我们设置了 id="storeString", 稍后设置字符串内容时,会读取网页内容将会用到。设置了两个<button>,用于与区块链交互。

styles.css 用于美化网页,可以完全不用