Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const promisify = (inner) =>
- new Promise((resolve, reject) =>
- inner((err, res) => {
- if (err) { reject(err) }
- resolve(res);
- })
- );
- const getBalance = (account, at) =>
- promisify(cb => web3.eth.getBalance(account, at, cb));
- // use getBalance
- const bigNumberBalance = await getBalance('0xabcdef');
- console.log(bigNumberBalance.toString());
- const getTransaction = (hash) =>
- promisify(cb => web3.eth.getTransaction(hash, cb));
- // use getTransaction
- const transaction = await getTransaction('0xcaff');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement