Is it possible get transaction history without contract variable?


I want to display history on my dApp. Actually, I am doing that;

contract Practice{

  struct History{
      address affector;
      string description;
      uint timestamp;

  event Affect(address affector, string description, uint timestamp);

  History[] public dummyHistory;


  function affectIt(string memory descriptions) public isAffected dummyIsExist(affectKey) {
       uint current_time = block.timestamp;

           affector: msg.sender,
           description: descriptions,
           timestamp: current_time
       emit Affect(msg.sender, descriptions, current_time);

  function getDummyHistory() public view returns(History[] memory) {
      return dummyHistory;

JS like this;

const history = await;
history.innerHTML = ''; // rm
history.length > 0 && history.reverse().map(h => appendHistoryItem(h.affector, h.description, Number(h.timestamp)));

How can I get my history with descriptions without contract logic? I don't know is it possible? Maybe we can fetch only transactions without description data. I want to descrement gas fee by when using affectIt function.

Thank you for interest.
Good works.

Hi, welcome! :wave:

I think if you want to show the history, you can monitor the contract events, use a database or The Graph to do this.

Thanks. I guess this is a commonly used method.

1 Like