Merge branch 'develop' of github.com:ethereum/web3.js into develop

This commit is contained in:
Fabian Vogelsteller 2015-05-13 18:07:33 +02:00
commit d02a3756c9
1 changed files with 18 additions and 1 deletions

View File

@ -44,10 +44,26 @@
// let's assume that coinbase is our account
web3.eth.defaultAccount = web3.eth.coinbase;
var watch = web3.eth.filter('latest');
// create contract
myContract = web3.eth.contract(desc).new({data: code});
console.log('address: ' + myContract.address);
document.getElementById('status').innerText = "transaction send, waiting for confirmation";
watch.watch(function (err, hash) {
var block = web3.eth.getBlock(hash, true);
var contractMined = block.transactions.reduce(function (mined, th) {
// TODO: compiled code do not have 0x prefix
return mined || (th.from === web3.eth.defaultAccount && th.input.indexOf(code) !== -1);
}, false);
if (contractMined) {
document.getElementById('status').innerText = 'Mined!';
document.getElementById('call').style.visibility = 'visible';
}
});
}
function callExampleContract() {
// this should be generated by ethereum
@ -63,6 +79,7 @@
<body>
<h1>contract</h1>
<div id="code"></div>
<div id="status"></div>
<div id='create'>
<button type="button" onClick="createExampleContract();">create example contract</button>
</div>