aboutsummaryrefslogtreecommitdiffstats
path: root/library/example
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-02-16 08:09:16 +0800
committerDan Finlay <dan@danfinlay.com>2017-02-16 08:09:16 +0800
commit6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf (patch)
tree47906b974dee789ffd544b4c85da67e6f2323016 /library/example
parent245e779f37763ce0633119c257877706d0bf3554 (diff)
parent943bcec0d702b2c70b323000ed25d3c425e2a44f (diff)
downloadtangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.tar
tangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.tar.gz
tangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.tar.bz2
tangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.tar.lz
tangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.tar.xz
tangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.tar.zst
tangerine-wallet-browser-6d103dc1e7eeb9a1f55e4387fcc1fe194c7eb4cf.zip
Merge branch 'kumavis-patch-1' of github.com:MetaMask/metamask-plugin into kumavis-patch-1
Diffstat (limited to 'library/example')
-rw-r--r--library/example/index.html17
-rw-r--r--library/example/index.js56
2 files changed, 73 insertions, 0 deletions
diff --git a/library/example/index.html b/library/example/index.html
new file mode 100644
index 000000000..47d6da34f
--- /dev/null
+++ b/library/example/index.html
@@ -0,0 +1,17 @@
+<!doctype html>
+
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+
+ <title>MetaMask ZeroClient Example</title>
+
+</head>
+
+<body>
+ <button class="action-button-1">SYNC TX</button>
+ <button class="action-button-2">ASYNC TX</button>
+ <script src="./zero.js"></script>
+ <script src="./app.js"></script>
+</body>
+</html> \ No newline at end of file
diff --git a/library/example/index.js b/library/example/index.js
new file mode 100644
index 000000000..4a107df6a
--- /dev/null
+++ b/library/example/index.js
@@ -0,0 +1,56 @@
+
+window.addEventListener('load', web3Detect)
+
+function web3Detect() {
+ if (global.web3) {
+ logToDom('web3 detected!')
+ startApp()
+ } else {
+ logToDom('no web3 detected!')
+ }
+}
+
+function startApp(){
+ console.log('app started')
+
+ var primaryAccount = null
+ console.log('getting main account...')
+ web3.eth.getAccounts(function(err, addresses){
+ if (err) throw err
+ console.log('set address', addresses[0])
+ primaryAccount = addresses[0]
+ })
+
+ document.querySelector('.action-button-1').addEventListener('click', function(){
+ console.log('saw click')
+ console.log('sending tx')
+ web3.eth.sendTransaction({
+ from: primaryAccount,
+ to: primaryAccount,
+ value: 0,
+ }, function(err, txHash){
+ if (err) throw err
+ console.log('sendTransaction result:', err || txHash)
+ })
+ })
+ document.querySelector('.action-button-2').addEventListener('click', function(){
+ console.log('saw click')
+ setTimeout(function(){
+ console.log('sending tx')
+ web3.eth.sendTransaction({
+ from: primaryAccount,
+ to: primaryAccount,
+ value: 0,
+ }, function(err, txHash){
+ if (err) throw err
+ console.log('sendTransaction result:', err || txHash)
+ })
+ })
+ })
+
+}
+
+function logToDom(message){
+ document.body.appendChild(document.createTextNode(message))
+ console.log(message)
+} \ No newline at end of file