I have the following code in the Solidity contract:

event Log(string text);

uint256 public number;

I need to put the variable within the Log text, just like when we use backticks in Javascript:

`This log outputs the ${number}`

Is there a way to do this in Solidity?

  • Is it not an option for you to change the signature of the event (or add a different event)? E.g. event LogNumber(uint256 number);. – user19510 Aug 24 '18 at 12:41
  • It is, but I'd like to listen to this event from the frontend, and receive and display it with the text, unless it's computationally more cheaper to add the text on the frontend. – Ruham Aug 24 '18 at 12:45
  • 1
    It would definitely be cheaper in terms of gas to convert to text on the front end. – user19510 Aug 24 '18 at 12:47
  • Thanks, and out of curiosity: is there a way to nest the events in Solidity? – Ruham Aug 24 '18 at 13:15
  • I don't understand what that would mean. – user19510 Aug 24 '18 at 13:26

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.