aboutsummaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-22 04:54:51 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-22 04:54:51 +0800
commitad8e92e9c67b82b0e8156345776bafe1c3e07d51 (patch)
tree9eb59d09860f1600f4048d26580f43576cb45f1e /example
parent81ff253e68bbc700ff093adcff0a21469460b4b8 (diff)
parentedfb874527160cee14cca931377e55187b874cbe (diff)
downloadgo-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.gz
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.bz2
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.lz
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.xz
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.tar.zst
go-tangerine-ad8e92e9c67b82b0e8156345776bafe1c3e07d51.zip
Merge commit 'eb4984c0d036c1420e782ca136810e851e33fb37' into natspec
Diffstat (limited to 'example')
-rw-r--r--example/balance.html18
-rw-r--r--example/contract.html14
2 files changed, 14 insertions, 18 deletions
diff --git a/example/balance.html b/example/balance.html
index d70ea648b..60b8bbe87 100644
--- a/example/balance.html
+++ b/example/balance.html
@@ -8,23 +8,21 @@
<script type="text/javascript">
var web3 = require('web3');
- web3.setProvider(new web3.providers.AutoProvider());
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
function watchBalance() {
var coinbase = web3.eth.coinbase;
var originalBalance = 0;
- web3.eth.balanceAt(coinbase).then(function (balance) {
- originalBalance = web3.toDecimal(balance);
- document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
- });
+ var balance = web3.eth.balanceAt(coinbase);
+ var originalBalance = web3.toDecimal(balance);
+ document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
web3.eth.watch({altered: coinbase}).changed(function() {
- web3.eth.balanceAt(coinbase).then(function (balance) {
- var currentBalance = web3.toDecimal(balance);
- document.getElementById("current").innerText = 'current: ' + currentBalance;
- document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
- });
+ balance = web3.eth.balanceAt(coinbase)
+ var currentBalance = web3.toDecimal(balance);
+ document.getElementById("current").innerText = 'current: ' + currentBalance;
+ document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
});
}
diff --git a/example/contract.html b/example/contract.html
index a3f0df176..3d0260d34 100644
--- a/example/contract.html
+++ b/example/contract.html
@@ -8,7 +8,7 @@
<script type="text/javascript">
var web3 = require('web3');
- web3.setProvider(new web3.providers.AutoProvider());
+ web3.setProvider(new web3.providers.HttpSyncProvider());
// solidity source code
var source = "" +
@@ -43,10 +43,9 @@
document.getElementById('source').innerText = source;
// create contract
- web3.eth.transact({code: web3.eth.solidity(source)}).then(function (address) {
- contract = web3.eth.contract(address, desc);
- document.getElementById('call').style.visibility = 'visible';
- });
+ var address = web3.eth.transact({code: web3.eth.solidity(source)});
+ contract = web3.eth.contract(address, desc);
+ document.getElementById('call').style.visibility = 'visible';
}
function callExampleContract() {
@@ -54,9 +53,8 @@
var param = parseInt(document.getElementById('value').value);
// call the contract
- contract.multiply(param).call().then(function(res) {
- document.getElementById('result').innerText = res[0];
- });
+ var res = contract.multiply(param).call();
+ document.getElementById('result').innerText = res[0];
}
</script>