Last active
November 4, 2024 15:18
-
-
Save ksaitor/6c832c106a8b9aee4f76a9145eb5d764 to your computer and use it in GitHub Desktop.
Revisions
-
ksaitor revised this gist
Dec 26, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ await ethereum.enable(); initPayButton() } catch (err) { $('#status').html('User denied account access', err) } } else if (window.web3) { window.web3 = new Web3(web3.currentProvider) -
ksaitor revised this gist
Dec 26, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const initPayButton = () => { $('.pay-button').click(() => { // paymentAddress is where funds will be send to const paymentAddress = '0x192c96bfee59158441f26101b2db1af3b07feb40' const amountEth = 1 -
ksaitor revised this gist
Dec 26, 2018 . 1 changed file with 32 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,30 +9,42 @@ <div id="status"></div> </div> <script type="text/javascript"> window.addEventListener('load', async () => { if (window.ethereum) { window.web3 = new Web3(ethereum); try { await ethereum.enable(); initPayButton() } catch (err) { console.log('User denied account access', err) } } else if (window.web3) { window.web3 = new Web3(web3.currentProvider) initPayButton() } else { $('#status').html('No Metamask (or other Web3 Provider) installed') } }) const initPayButton = () => { $('.pay-button').click(() => { const paymentAddress = '0x192c96bfee59158441f26101b2db1af3b07feb40' const amountEth = 1 web3.eth.sendTransaction({ to: paymentAddress, value: web3.toWei(amountEth, 'ether') }, (err, transactionId) => { if (err) { console.log('Payment failed', err) $('#status').html('Payment failed') } else { console.log('Payment successful', transactionId) $('#status').html('Payment successful') } }) }) } </script> </body> </html> -
ksaitor revised this gist
Dec 26, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,12 +19,12 @@ web3.eth.sendTransaction({ to: paymentAddress, value: web3.toWei(amountEth, 'ether') }, (err, transactionId) => { if (err) { console.log('Payment failed', err) $('#status').html('Payment failed') } else { console.log('Payment successful', transactionId) $('#status').html('Payment successful') } }) -
ksaitor created this gist
Dec 26, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div> <button class="pay-button">Pay</button> <div id="status"></div> </div> <script type="text/javascript"> $(() => { if (typeof web3 !== 'undefined') { $('.pay-button').click(() => { const paymentAddress = '0x192c96bfee59158441f26101b2db1af3b07feb40' const amountEth = 1 web3.eth.sendTransaction({ to: paymentAddress, value: web3.toWei(amountEth, 'ether') }, (err, data) => { if (err) { console.log('Payment failed', err) $('#status').html('Payment failed') } else { console.log('Payment successful', data) $('#status').html('Payment successful') } }) }) } else { $('#status').html('No Metamask (or other Web3 Provider) installed') } }) </script> </body> </html>