Merge branch 'develop' of github.com:ethereum/web3.js into develop
This commit is contained in:
commit
d02a3756c9
|
@ -44,10 +44,26 @@
|
||||||
// let's assume that coinbase is our account
|
// let's assume that coinbase is our account
|
||||||
web3.eth.defaultAccount = web3.eth.coinbase;
|
web3.eth.defaultAccount = web3.eth.coinbase;
|
||||||
|
|
||||||
|
var watch = web3.eth.filter('latest');
|
||||||
|
|
||||||
// create contract
|
// create contract
|
||||||
myContract = web3.eth.contract(desc).new({data: code});
|
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';
|
document.getElementById('call').style.visibility = 'visible';
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function callExampleContract() {
|
function callExampleContract() {
|
||||||
// this should be generated by ethereum
|
// this should be generated by ethereum
|
||||||
|
@ -63,6 +79,7 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>contract</h1>
|
<h1>contract</h1>
|
||||||
<div id="code"></div>
|
<div id="code"></div>
|
||||||
|
<div id="status"></div>
|
||||||
<div id='create'>
|
<div id='create'>
|
||||||
<button type="button" onClick="createExampleContract();">create example contract</button>
|
<button type="button" onClick="createExampleContract();">create example contract</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue