aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/example/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'mascara/example/index.js')
-rw-r--r--mascara/example/index.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/mascara/example/index.js b/mascara/example/index.js
new file mode 100644
index 00000000..aae7ccd1
--- /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)
+}
edc0c21e5fad66336cc6097d505cd19ff7c692f'>Bump PORTREVISION from this morning's commitsjeh2001-02-131-1/+1 * Allow -client & -server to be at different REVISIONSjeh2001-01-311-0/+1 * Complete the CLIENT Makefilejeh2001-01-315-139/+7 * I will take this for awhilejeh2001-01-301-1/+1 * Make the Makefile portlint clean.jeh2001-01-292-1/+2 * Amanda 2.4.2. Uses gmake to work around bin/23328. Changer support enabled ...cwt2001-01-285-102/+33 * Remove inactive MAINTAINER <cwt>, who hasn't committed in 20 months.will2001-01-271-1/+1 * Rename INSTALLS_SHLIBS to INSTALLS_SHLIB. (There was a typo in theasami2000-06-171-1/+1 * Fix MASSIVE typo INSTALL_SHLIBS --> INSTALLS_SHLIBS, which occured because Isobomax2000-06-161-1/+1 * Second round of INSTALL_SHLIBS=yes fixes.sobomax2000-06-162-2/+1 * Convert to PORTNAME/PORTVERSION.asami2000-04-141-3/+3