Last active
June 27, 2020 22:26
-
-
Save yakkomajuri/cafbd3ac182f9cb1669a019392727983 to your computer and use it in GitHub Desktop.
This file contains 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 characters
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> | |
<script src="http://rawgit.com/ethereum/web3.js/0.16.0/dist/web3.min.js"></script> | |
<script> | |
if (typeof web3 !== 'undefined') { | |
web3 = new Web3(web3.currentProvider); | |
} else { | |
web3 = new Web3(new Web3.providers.HttpProvider("SUA URL DO NÓ AQUI")); | |
} | |
var account = web3.eth.accounts[0]; | |
var accountInterval = setInterval(function () { | |
var accountInterval = setInterval(function () { | |
if (web3.eth.accounts[0] !== account) { | |
account = web3.eth.accounts[0]; | |
document.getElementById("address").innerHTML = account; | |
} | |
}, 100); | |
}); | |
var HodlContract = web3.eth.contract(SUA ABI AQUI); | |
window.alert('Sua mensagem aqui.'); | |
var Hodl = HodlContract.at('ENDEREÇO DO CONTRATO'); | |
console.log(Hodl); | |
address = account | |
$("#button1").click(function (web3) { | |
var tx = Hodl.depositarInvestimento({ | |
from: address, | |
gas: "3000000", | |
to: "ENDEREÇO DO CONTRATO", | |
value: 1000000000000000000 * ($("#valor")[0].value), | |
data: "" | |
}, function (err, transactionHash) { | |
if (!err) | |
console.log(transactionHash); | |
}) | |
}) | |
$("#button2").click(function (web3) { | |
var tx = Hodl.retirarInvestimento("\"" + $("#senha")[0].value + "\"", { | |
from: address, | |
gas: "3000000", | |
to: "ENDEREÇO DO CONTRATO", | |
value: "0", | |
data: "" | |
}, function (err, transactionHash) { | |
if (!err) | |
console.log(transactionHash); | |
}) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment