0

I am trying to make a code in solidity to add items to a blockchain which contains items and their tracking history (like when trace your order online for an item) (which at first are located in "check in office" and time/date is also recorded) and I want to be able to update each item reason-location (one string) and automatically record the time/date of that action by searching their name. I want to store and show a tracking history of reasons-locations with time and date for each item when user search for that using it's name.

I am confused. Do I need two blockchains? How to keep and update the tracking history for each item with time and date?

contract traceitems {

    struct item {
        uint id;
    string name;
        string reason;
    }
 struct Action {
    // @dev Instant of time when the Action is done.
    uint timestamp;
    // @dev Block when the Action is done.
    uint blockNumber;
  }




    mapping(uint => item) public items;


    uint public itemsCount;


    function additem (string _name,string _reason) private {
        itemsCount ++;
        items[itemsCount] = item(itemsCount,_name, _reason);
    }
  function traceitems () public {
        additem(..,..);

    }



  uint value;
  mapping (uint256 => item) public  datamatching;

function getData(uint256 name) returns (uint, ustring, ustring){
    return (datamatching[].id, datamatching[].name, datamatching[].reason);
  }
------------------------------------------------------------------

    function trackitem (string _name) private {
    action.timestamp = now;
    action.blockNumber = block.number;
    var  itemdata  = datamatching[value];
    items[itemdata] = _reason;
    }




  function storedata (string _reason) public {
    var  artifactdata  = datamatching[value];
    artifactdata .reason = _reason;

  }



}
  • Can you give a practical example of what are you trying to achieve? In general it is not a good idea to use Ethereum blockchain to store and query large amounts of data. – Ismael Nov 20 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.