Reader small image

You're reading from  Truffle Quick Start Guide

Product typeBook
Published inJun 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789132540
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Nikhil Bhaskar
Nikhil Bhaskar
author image
Nikhil Bhaskar

Nikhil Bhaskar is the founder and CEO of Ulixir Inca newly founded tech company that builds decentralized and traditional software. He completed B9lab's Ethereum Developer Course, and he is now a certified Ethereum developer. Aside from running Ulixir, he spends his time traveling and eating. He is a bit of a digital nomad; this year, he's lived in five countries and plans to live in six more before the year ends.
Read more about Nikhil Bhaskar

Right arrow

Testing for Solidity events

We briefly touched on testing for events but we did not get into much detail. Now is the time.

Events are a great way to let the client (frontend) know what has happened, and they're great for providing metadata about a transaction or public function invocation of your Solidity smart contract. Along with testing the state modifications of a transaction, return value of a view function, and modifiers, we can also test whether an event was emitted with the appropriate metadata.

Right now, our TaskMaster contract has no events. Let's quickly add one.

Inside the TaskMaster.sol file, underneath the state variable declarations and before the constructor, add the following line of code:

event LogRecipientRewarded(address recipient, uint rewardAmount);

This is how you declare an event in Solidity.

We call it LogRecipientRewarded. We also specify the...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Truffle Quick Start Guide
Published in: Jun 2018Publisher: PacktISBN-13: 9781789132540

Author (1)

author image
Nikhil Bhaskar

Nikhil Bhaskar is the founder and CEO of Ulixir Inca newly founded tech company that builds decentralized and traditional software. He completed B9lab's Ethereum Developer Course, and he is now a certified Ethereum developer. Aside from running Ulixir, he spends his time traveling and eating. He is a bit of a digital nomad; this year, he's lived in five countries and plans to live in six more before the year ends.
Read more about Nikhil Bhaskar