OSDN Git Service

feat: add dapp-example
authormonky <monky@it709.com>
Sun, 6 Jan 2019 09:39:09 +0000 (17:39 +0800)
committermonky <monky@it709.com>
Sun, 6 Jan 2019 09:39:09 +0000 (17:39 +0800)
dapp-example/index.html [new file with mode: 0644]

diff --git a/dapp-example/index.html b/dapp-example/index.html
new file mode 100644 (file)
index 0000000..8176cab
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>bytom-chrome-extension-test</title>
+  </head>
+  <body>
+    <input type="text" id="to" name="to" placeholder="to address" />
+    <input type="number" id="amount" name="amount" placeholder="amount" />
+    <a id="transferButton" href="#">transfer</a>
+
+    <script type="text/javascript">
+      var getById = function(id) {
+        return document.getElementById(id)
+      }
+
+      var bytom
+      getById('transferButton').addEventListener('click', () => {
+        bytom.transfer(getById('to').value, getById('amount').value)
+      })
+
+      // 监听Bytom插件加载成功事件
+      document.addEventListener('chromeBytomLoaded', () => {
+        console.log('chromeBytomLoaded')
+        bytom = window.bytom
+      })
+    </script>
+  </body>
+</html>