-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.js
More file actions
25 lines (19 loc) · 709 Bytes
/
query.js
File metadata and controls
25 lines (19 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var Web3 = require('web3');
var web3 = new(Web3);
var contract = require('truffle-contract');
var config = require('./config');
var account = config.account_two;
var metacoin_artifacts = require('./build/contracts/MetaCoin.json');
var MetaCoin = contract(metacoin_artifacts);
var meta;
// Bootstrap the MetaCoin abstraction for Use.
MetaCoin.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
MetaCoin.deployed().then(function(instance) {
meta = instance;
return meta.getBalance.call(account, {from: account});
}).then(function(balance) {
console.log(`Balance is ${balance.toNumber()}\n`);
}).catch(function(err) {
// There was an error! Handle it.
console.log(err);
});