diff options
author | kumavis <kumavis@users.noreply.github.com> | 2016-09-14 02:29:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-14 02:29:46 +0800 |
commit | b13eaaa0cd201704a63e30f3601552c136c9278c (patch) | |
tree | a2b85fba2f42921ce2c9afb158f6bcad787f4ea0 /library/example | |
parent | b4344f2a02ac7b130fc69bbb772f68b4d042b49c (diff) | |
parent | 81d25d560f4920ee7a357881931e674bea97176c (diff) | |
download | tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.tar tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.tar.gz tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.tar.bz2 tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.tar.lz tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.tar.xz tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.tar.zst tangerine-wallet-browser-b13eaaa0cd201704a63e30f3601552c136c9278c.zip |
Merge pull request #651 from MetaMask/library
MetaMask "Mascara" Library - initial PR
Diffstat (limited to 'library/example')
-rw-r--r-- | library/example/index.html | 17 | ||||
-rw-r--r-- | library/example/index.js | 54 |
2 files changed, 71 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..a3f4b9859 --- /dev/null +++ b/library/example/index.js @@ -0,0 +1,54 @@ + +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') + primaryAccount = addresses[0] + }) + + document.querySelector('.action-button-1').addEventListener('click', function(){ + console.log('saw click') + console.log('sending tx') + web3.eth.sendTransaction({ + from: 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, + 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 |