You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<a href="https://github.com/MetaMask/TipButton">View on Github</a>
<div class="tip-button"></div>
<div class="message"></div>
</body>
<script>
var MY_ADDRESS = '0x55e2780588aa5000F464f700D2676fD0a22Ee160'
var tipButton = document.querySelector('.tip-button')
tipButton.addEventListener('click', function() {
if (typeof web3 === 'undefined') {
return renderMessage('<div>You need to install <a href=“https://metmask.io“>MetaMask </a> to use this feature. <a href=“https://metmask.io“>https://metamask.io</a></div>')
}
var user_address = web3.eth.accounts[0]
web3.eth.sendTransaction({
to: MY_ADDRESS,
from: user_address,
value: web3.toWei('1', 'ether'),
}, function (err, transactionHash) {
if (err) return renderMessage('There was a problem!: ' + err.message)
// If you get a transactionHash, you can assume it was sent,
// or if you want to guarantee it was received, you can poll
// for that transaction to be mined first.
renderMessage('Thanks for the generosity!!')
})
})
function renderMessage (message) {
var messageEl = document.querySelector('.message')