0

I'm using solidity compiler ^0.4.23, I added logs to the function at exception points like this:

function firstSaleDelivery(address _beneficiary, uint256 rate) public onlyOwner{
  require(!presaleOpen && !firstsaleOpen, "First Sale is NOT CLOSE");
  if(preSaleTokens >= 0){
      saleTokens = saleTokens.add(preSaleTokens);
      preSaleTokens = 0;
  }
  uint256 ethers = firstSaleFunds[_beneficiary];
  uint256 tokens = ethers.mul(rate);    // <u>
  require(saleTokens >= tokens, "NO Sale Tokens Available");
  if(ethers >= 5 && ethers <= 9 ){
    tokens.add((tokens.mul(10)).div(100));            // <u>
  }
  else if(ethers >= 10 && ethers <= 200 ){
    tokens.add((tokens.mul(25)).div(100));            // <u>
  }
  token.transfer(_beneficiary,tokens);
  saleTokens = saleTokens.sub(tokens);

}

When I invoke the function, and if I face any exception, I can't see these Logs, where I can see them?

Fariha Abbasi
  • 333
  • 1
  • 4
  • 16

2 Answers2

1

Logs are not produced if the transaction reverts (see this answer: Is it possible to retrieve an event log from a reverted transaction?).

Thomas Jay Rush
  • 9,943
  • 4
  • 31
  • 72
1

The reason string is a very new addition to revert and require (about one week old). I believe that Geth's DebugTrace exposes the reason string, but otherwise I'm not sure there's tooling support yet.

I imagine that soon enough Etherscan will just surface them, but at the moment, reason strings are not particularly accessible to end users.

user19510
  • 27,999
  • 2
  • 30
  • 48
  • As I understand, if there is an exceptition, the TX is never mined and so it will never be present on Etherscan. Is that correct? – earizon Jun 11 '18 at 13:05
  • 1
    No, that's incorrect. Transactions that revert are still mined and still cost gas. – user19510 Jun 11 '18 at 13:06
  • 1
    Here's a recent transaction that reverted: https://etherscan.io/tx/0x9f00a37416a64735b02ab76da4477ea297bfd4923b1564c1b3579d542b3f4071. – user19510 Jun 11 '18 at 13:07