0
votes

I created a Ethereum smart contract with remix IDE and metamask for the ethereum ropsten network. The smart contract is created and transactions are made. But the events does not log any Events.

The code for generating smart contract is shown below.

pragma solidity ^0.5.1;
contract SimpleStorage{
uint storeddata;
function set(uint x) public{
storeddata = x;

}
function get() public view returns(uint){
return storeddata;

}
}

The smart contract address obtained is

0xA41B2508Ee53cE00E07405Bc15A190F8af5dE0a4

What could be the reason for the events not getting logged.

1
You dont have intialized event which to be emitted in set functionAndon Mitev

1 Answers

2
votes

This is because there is no events registered when running the above code. you can re-write the code as below.

pragma solidity ^0.5.1;
contract SimpleStorage{
uint storeddata;

event Store(uint _value);

function set(uint x) public{

emit Store(x);

storeddata = x;
}
function get() public view returns(uint){


return storeddata;

}
}

The line four and six should solve your problem