Skip to content

Instantly share code, notes, and snippets.

@sogoiii
Created September 1, 2017 21:53
Show Gist options
  • Save sogoiii/550fa3f0624b92cdf328f6e4709c7b46 to your computer and use it in GitHub Desktop.
Save sogoiii/550fa3f0624b92cdf328f6e4709c7b46 to your computer and use it in GitHub Desktop.
Interact with a deployed solidity contract
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