pragma solidity ^0.4.18; contract TransManager { //state variables // contract owner address private creator; uint transCounter; // File Meta metaData struct metaData{ uint id; address owner; string docType; string fileHash; } //Array to store tranasactions mapping (address => metaData[]) fileLogs; //Send a trnsactionId function regTransaction(string _docType, string _fileHash) public { transCounter++; var fileLog = metaData(transCounter, msg.sender, _docType, _fileHash ); fileLogs[msg.sender].push(fileLog); } function getTransactions() public returns (uint []){ var temp = fileLogs[msg.sender]; uint[] memory ids = new uint[](transCounter); for (uint i=0; i<= transCounter; i++){ ids[i]=temp[i].id; } return ids; } // constructor function TransManager() { creator = msg.sender; } // kills contract and sends remaining funds back to creator function kill() { if (msg.sender == creator) { selfdestruct(creator); } } } getTransactions - is always returning array of zeros. But I am expecting to return the indexed number.