diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-04-03 17:08:31 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-04-03 17:09:03 +0800 |
commit | 57655073f6ab4e93b9947302d46a20bd2c7288f1 (patch) | |
tree | 3bce06d9ccd8f003cec720b8444d489e1ed6c050 /mascara/example | |
parent | 9736e96a93799f081ede01bc7ecd295fa264ffd5 (diff) | |
download | tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.tar tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.tar.gz tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.tar.bz2 tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.tar.lz tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.tar.xz tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.tar.zst tangerine-wallet-browser-57655073f6ab4e93b9947302d46a20bd2c7288f1.zip |
Rename mascara root directory
Diffstat (limited to 'mascara/example')
-rw-r--r-- | mascara/example/index.html | 17 | ||||
-rw-r--r-- | mascara/example/index.js | 57 |
2 files changed, 74 insertions, 0 deletions
diff --git a/mascara/example/index.html b/mascara/example/index.html new file mode 100644 index 000000000..47d6da34f --- /dev/null +++ b/mascara/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/mascara/example/index.js b/mascara/example/index.js new file mode 100644 index 000000000..aae7ccd19 --- /dev/null +++ b/mascara/example/index.js @@ -0,0 +1,57 @@ +window.addEventListener('load', web3Detect) +window.addEventListener('message', console.warn) + +function web3Detect() { + if (global.web3) { + logToDom('web3 detected!') + startApp() + } else { + logToDom('no web3 detected!') + } +} + +function startApp(){ + console.log('app started') + + var primaryAccount + console.log('getting main account...') + web3.eth.getAccounts((err, addresses) => { + if (err) console.error(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') + primaryAccount + 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) +} |