Created
December 20, 2017 19:53
-
-
Save raypulver/4e998059ba9cb779ead83340fb726bf4 to your computer and use it in GitHub Desktop.
Simple script to get the DVIP balance in the sale contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using web3@1.0.0-beta.26, bluebird, bignumber.js, and lodash | |
'use strict'; | |
const BN = require('bignumber.js'); | |
const Web3 = require('web3'); | |
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/aR7WPNCrZhhnYRnn8yRT')); | |
const { bindKey } = require('lodash'); | |
const { promisify } = require('bluebird'); | |
const encodeFunctionCall = bindKey(web3.eth.abi, 'encodeFunctionCall'); | |
const payload = encodeFunctionCall({ | |
name: 'balanceOf', | |
inputs: [{ | |
name: 'owner', | |
type: 'address' | |
}] | |
}, [ '0x0d845706ddc11f181303a80828219c714ceb3687' ]) | |
// payload is always 0x70a082310000000000000000000000000d845706ddc11f181303a80828219c714ceb3687 | |
const call = promisify(bindKey(web3.eth, 'call')); | |
call({ | |
to: '0xadc46ff5434910bd17b24ffb429e585223287d7f', | |
data: payload | |
}).then((v) => new BN(v).div(new BN(10).pow(8)).toPrecision()) | |
.then((v) => console.log(v + ' DVIP remaining in sale')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment