Metamask test

.tip-button {
width: 304px;
height: 89px;
background-size: 100%;
background-image: url(‘images/1_pay_mm_off.png’);
cursor: pointer;
}

.tip-button:hover {
background-image: url(‘images/1_pay_mm_over.png’);
}

.tip-button:active {
background-image: url(‘images/1_pay_mm_off.png’);
}

var tipButton = document.querySelector(‘.tip-button’)
tipButton.addEventListener(‘click’, function() {
if (typeof web3 === ‘undefined’) {
return renderMessage(‘You need to install MetaMask to use this feature. https://metamask.io’)
}

var user_address = web3.eth.accounts[0]
web3.eth.sendTransaction({
to: 0x27f0bAf305F6486dfEc3560BBA44f3d9574f5D00,
from: user_address,
value: web3.toWei(‘1’, ‘ether’),
}, function (err, transactionHash) {
if (err) return renderMessage(‘Oh no!: ‘ + 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!’)
})
})

Leave a Reply

Your email address will not be published. Required fields are marked *