Created
September 1, 2017 21:53
-
-
Save sogoiii/550fa3f0624b92cdf328f6e4709c7b46 to your computer and use it in GitHub Desktop.
Interact with a deployed solidity contract
This file contains hidden or 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
const Web3 = require('web3') | |
const fs = require('fs') | |
const ethereumURL = 'http://0.0.0.0:8545' | |
const provider = new Web3.providers.HttpProvider(ethereumURL) | |
const web3 = new Web3(provider) | |
const contractInfo = JSON.parse(fs.readFileSync('./MetaCoinABI.js', 'utf8')) | |
const MyContract = web3.eth.contract(contractInfo.abi); | |
const contractInstance = MyContract.at(contractInfo.address); | |
console.log(contractInstance) | |
contractInstance.getBalance.call('0x01', function(err, result){ | |
console.log('---') | |
console.log(err) | |
console.log('---') | |
console.log(result.toString()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment