Hardhat console.log Integration¶
(Supported since Remix IDE v0.17.0)
Hardhat Network allows you to print logging messages and contract variables by calling console.log() from your Solidity code. To use it, you simply import
hardhat/console.sol and call it.
console.log in Remix IDE¶
Remix IDE supports hardhat console library while using
Deploy and Run Transactions¶
To try it out, you need to put an import statement and use
console.log to print the value as shown in image.
Further, once you execute the
changeOwner method, value from console statement will be shown in Remix terminal after transaction details as below:
Solidity Unit Testing¶
console.log can be used while running unit tests using Remix Solidity Unit Testing plugin. See image below.
For the tests including logging message, it will display in the Remix Terminal corresponding to test name.