aboutsummaryrefslogtreecommitdiffstats
path: root/library/example/index.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-08-27 02:08:23 +0800
committerkumavis <aaron@kumavis.me>2016-08-27 02:08:23 +0800
commit23a144fb8b0b214b9c352ee523405d5ecd03046e (patch)
tree43e464ffc4eac01ecba092e758aee3e9b03c8b17 /library/example/index.js
parentbbb684309e04030dbf288f3e933222b3d27d9b54 (diff)
downloadtangerine-wallet-browser-23a144fb8b0b214b9c352ee523405d5ecd03046e.tar.gz
tangerine-wallet-browser-23a144fb8b0b214b9c352ee523405d5ecd03046e.tar.zst
tangerine-wallet-browser-23a144fb8b0b214b9c352ee523405d5ecd03046e.zip
library - popup handler demo
Diffstat (limited to 'library/example/index.js')
-rw-r--r--library/example/index.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/library/example/index.js b/library/example/index.js
new file mode 100644
index 000000000..d24c26f87
--- /dev/null
+++ b/library/example/index.js
@@ -0,0 +1,42 @@
+
+window.addEventListener('load', web3Detect)
+
+function web3Detect() {
+ if (global.web3) {
+ document.body.innerHTML += 'web3 detected!'
+ } else {
+ document.body.innerHTML += 'no web3 detected!'
+ }
+ startApp()
+}
+
+var primaryAccount = null
+web3.eth.getAccounts(function(err, addresses){
+ if (err) throw err
+ primaryAccount = addresses[0]
+})
+
+
+function startApp(){
+ document.querySelector('.action-button-1').addEventListener('click', function(){
+ 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(){
+ setTimeout(function(){
+ web3.eth.sendTransaction({
+ from: primaryAccount,
+ value: 0,
+ }, function(err, txHash){
+ if (err) throw err
+ console.log('sendTransaction result:', err || txHash)
+ })
+ })
+ })
+
+}