I'm using testrpc, truffle, and web3 in Node. I've written my contract and pushed it to testrpc with truffle. Here's the gist of the Node code I have so far:
let fs = require('fs');
let Web3 = require('web3');
let web3 = new Web3();
let settings = require('./settings.json'); // my own settings file
let abiContractContent = fs.readFileSync(settings.contractAbiPath, 'utf8');
let abi = JSON.parse(abiContractContent);
let contract = web3.eth.contract(abi).at(settings.contractAddress);
web3.eth.defaultAccount = web3.eth.accounts[0];
I've then found two ways to call a function in my contract:
contract.myFunc(param1, param2, { gas: 200000 });
which returns what I believe is the transaction ID for the changes caused by that function call.
contract.myFunc.call(param1, param2, { gas: 200000 });
which gives me the actual return value of myFunc
.
I would like to have all of these pieces of information: the transaction AND the return values. I imagine I would need to call my function using the first approach and then look up the return values using the transaction ID but I have no idea how to actually do that. Am I on the right track or should I be looking for an entirely different approach?