|
|
@ -9,7 +9,7 @@ |
|
|
|
<script type="text/javascript"> |
|
|
|
|
|
|
|
var web3 = require('web3'); |
|
|
|
web3.setProvider(new web3.providers.AutoProvider()); |
|
|
|
web3.setProvider(new web3.providers.QtSyncProvider()); |
|
|
|
|
|
|
|
// solidity source code |
|
|
|
var source = "" + |
|
|
@ -45,20 +45,19 @@ |
|
|
|
document.getElementById('source').innerText = source; |
|
|
|
|
|
|
|
// create contract |
|
|
|
web3.eth.transact({code: web3.eth.solidity(source)}).then(function (address) { |
|
|
|
var address = web3.eth.transact({code: web3.eth.solidity(source)}); |
|
|
|
contract = web3.eth.contract(address, desc); |
|
|
|
document.getElementById('call').style.visibility = 'visible'; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function callExampleContract() { |
|
|
|
// this should be generated by ethereum |
|
|
|
var param = parseInt(document.getElementById('value').value); |
|
|
|
|
|
|
|
// call the contract |
|
|
|
contract.multiply(param).transact().then(function(res) { |
|
|
|
document.getElementById('result').innerText = res[0]; |
|
|
|
}); |
|
|
|
// transaction does not return any result, cause it's not synchronous and we don't know, |
|
|
|
// when it will be processed |
|
|
|
contract.multiply(param).transact(); |
|
|
|
document.getElementById('result').innerText = 'transaction made'; |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|