I have a function in my contract which normally return uint
function insertPerson(
bytes32 personAddress,
bytes32 email,
bytes32 fname,
bytes32 lname)
public
returns(uint index)
{
if(isPerson(personAddress)) return;
persons[personAddress].email = email;
persons[personAddress].fname = fname;
persons[personAddress].lname = lname;
persons[personAddress].index = personIndex.push(personAddress)-1;
LogNewPerson(
personAddress,
persons[personAddress].index,
email,
fname,
lname);
return personIndex.length-1;
}
but instead of getting the index i'm getting information about the transaction something like this
{"tx":"0xcfe28fe4cffeb7aa97c2db856920f7a3275d55a656f0550e7f78b76d446970b8","receipt":{"transactionHash":"0xcfe28fe4cffeb7aa97c2db856920f7a3275d55a656f0550e7f78b76d446970b8","transactionIndex":0,"blockHash":"0xcaa35831f7652155de33af8a349e4d5727026d20ec2f280c45d5a8109c8ca1e4","blockNumber":14,"gasUsed":134146,"cumulativeGasUsed":134146,"contractAddress":null,"logs":[{"logIndex":0,"transactionIndex":0,"transactionHash":"0xcfe28fe4cffeb7aa97c2db856920f7a3275d55a656f0550e7f78b76d446970b8","blockHash":"0xcaa35831f7652155de33af8a349e4d5727026d20ec2f280c45d5a8109c8ca1e4","blockNumber":14,"address":"0xf3b5fccbaea5a0bd10542d13c58d808e18aaef9f","data":"0x0000000000000000000000000000000000000000000000000000000000000008646576407369622e636f6d000000000000000000000000000000000000000000646576000000000000000000000000000000000000000000000000000000000061646d696e000000000000000000000000000000000000000000000000000000","topics":["0xa7cb2773240099bbe7a853382f1c2141cd85ac771e1ca8b9c8778fa5a901076e","0x3035343734393837000000000000000000000000000000000000000000000000"],"type":"mined"}],"status":1},"logs":[{"logIndex":0,"transactionIndex":0,"transactionHash":"0xcfe28fe4cffeb7aa97c2db856920f7a3275d55a656f0550e7f78b76d446970b8","blockHash":"0xcaa35831f7652155de33af8a349e4d5727026d20ec2f280c45d5a8109c8ca1e4","blockNumber":14,"address":"0xf3b5fccbaea5a0bd10542d13c58d808e18aaef9f","type":"mined","event":"LogNewPerson","args":{"personAddress":"0x3035343734393837000000000000000000000000000000000000000000000000","index":"8","email":"0x646576407369622e636f6d000000000000000000000000000000000000000000","fname":"0x6465760000000000000000000000000000000000000000000000000000000000","lname":"0x61646d696e000000000000000000000000000000000000000000000000000000"}}]}
can someone help me please, thanks.
code
contractInstance.insertPerson( web3.fromAscii(String(cin)), email, fname, lname, {gas: 3000000, from: web3.eth.accounts[0]}).then( function(v) { console.log(JSON.stringify(v)); }); – friedman1987 Jan 26 '18 at 11:08