manniru
3/3/2018 - 11:02 AM

truffle1.js

// Import libraries

var Web3            = require('web3'),
    contract        = require("truffle-contract"),
    path            = require('path')
    MyContractJSON  = require(path.join(__dirname, '../build/contracts/MetaCoin.json'));
    

    // Setup RPC connection   
    var provider    = new Web3.providers.HttpProvider("http://localhost:7545");


    // Read JSON and attach RPC connection (Provider)
    var MyContract = contract(MyContractJSON);
    MyContract.setProvider(provider);

    // Use Truffle as usual
    MyContract.deployed().then(function(instance) {
      //return instance.getBalance.call(arg1, arg2, {from: '0x627306090abaB3A6e1400e9345bC60c78a8BEf57'})
      return instance.getBalance.call('0x627306090abaB3A6e1400e9345bC60c78a8BEf57')

    }).then(function(result) {
        console.log(result);

    }, function(error) {
        console.log(error);
    });