pragma solidity ^0.4.23;
contract ChainList {
struct data {
uint ownernumber;
uint id;
}
uint value;
mapping (uint256 => data) public datamatching;
function storedata (uint _ownernumber, uint _id) public {
var persondata = datamatching[value];
persondata .ownernumber = _ownernumber;
persondata. id = _id;
}
function getData(uint256 userId) returns (uint, uint){
return (datamatching[userId].ownernumber, datamatching[userId].id);
}
}
// I have written the function but I tought that when I call the get function it will return all the child varables but it is not working
truffle(development)> app.storedata(123344,1)
{ tx: '0x1fad231de1e19b004c8004871036a7cf47be06ab4123614130f1b1371371433b',
receipt:
{ transactionHash: '0x1fad231de1e19b004c8004871036a7cf47be06ab4123614130f1b1371371433b',
transactionIndex: 0,
blockHash: '0xbff254564dc0d2e8affc80ca5994a66be5c06377f98ff425783c9b02fd36c75c',
blockNumber: 20,
gasUsed: 62379,
cumulativeGasUsed: 62379,
contractAddress: null,
logs: [],
status: 1 },
logs: [] }
truffle(development)> app.getData(123344)
{ tx: '0x327089e695085696d00c5656db322bce490bc17bf0edaa19f17dad38cdf74377',
receipt:
{ transactionHash: '0x327089e695085696d00c5656db322bce490bc17bf0edaa19f17dad38cdf74377',
transactionIndex: 0,
blockHash: '0x85ccd6ccc26417365681525442b0349ce29a1a46b9de4184ca1f1e3ec4b66fd4',
blockNumber: 21,
gasUsed: 22454,
cumulativeGasUsed: 22454,
contractAddress: null,
logs: [],
status: 1 },
logs: [] }
truffle(development)>
undefined
truffle(development)>
undefined
truffle(development)> app.storedata(123344,3)
{ tx: '0xafb132e70bfb82e1d41227bf41d787faaf6ee9d99c63fa3145752e2178b5a4e6',
receipt:
{ transactionHash: '0xafb132e70bfb82e1d41227bf41d787faaf6ee9d99c63fa3145752e2178b5a4e6',
transactionIndex: 0,
blockHash: '0x61dacd6a0a2d48627b3becc2a815ec7b72a7fe175497ef66964dffdd3bdf2c6f',
blockNumber: 22,
gasUsed: 32379,
cumulativeGasUsed: 32379,
contractAddress: null,
logs: [],
status: 1 },
logs: [] }
truffle(development)> app.getData(123344)
{ tx: '0x63c83f31d384494ed8ad6389c43d2a5745a6e229242c5fb6218386b3387d6409',
receipt:
{ transactionHash: '0x63c83f31d384494ed8ad6389c43d2a5745a6e229242c5fb6218386b3387d6409',
transactionIndex: 0,
blockHash: '0x7c3252574ffcd2f65f207b279d1b7501655e2638ddd52397c8fde93a9be4cb00',
blockNumber: 23,
gasUsed: 22454,
cumulativeGasUsed: 22454,
contractAddress: null,
logs: [],
status: 1 },
logs: [] }
When I call getData with id 123344 it should return the two values 1 and 3 because I used the same id to store the both varibles but it is showing a different hash.
I want to getdata to show the hash of the two transactions id's and the values 1 and 2 when user calls it.