aboutsummaryrefslogtreecommitdiffstats
path: root/library/example/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/example/index.js')
-rw-r--r--library/example/index.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/library/example/index.js b/library/example/index.js
index 4a107df6a..aae7ccd19 100644
--- a/library/example/index.js
+++ b/library/example/index.js
@@ -1,5 +1,5 @@
-
window.addEventListener('load', web3Detect)
+window.addEventListener('message', console.warn)
function web3Detect() {
if (global.web3) {
@@ -13,10 +13,10 @@ function web3Detect() {
function startApp(){
console.log('app started')
- var primaryAccount = null
+ var primaryAccount
console.log('getting main account...')
- web3.eth.getAccounts(function(err, addresses){
- if (err) throw err
+ web3.eth.getAccounts((err, addresses) => {
+ if (err) console.error(err)
console.log('set address', addresses[0])
primaryAccount = addresses[0]
})
@@ -24,6 +24,7 @@ function startApp(){
document.querySelector('.action-button-1').addEventListener('click', function(){
console.log('saw click')
console.log('sending tx')
+ primaryAccount
web3.eth.sendTransaction({
from: primaryAccount,
to: primaryAccount,
@@ -53,4 +54,4 @@ function startApp(){
function logToDom(message){
document.body.appendChild(document.createTextNode(message))
console.log(message)
-} \ No newline at end of file
+}