1

how to read the output of console.log() (it doesn't appear on my hardhat node console ) when i m running a smart contract on goerli (alchemy) via a js script (hardhat) ?

import "hardhat/console.sol";
contract BookStore {
function hello() external {
console.log("hello");}  
}

2 Answers 2

2

You can not see the console.log on testnet/mainnet. If your want the logs for testing, you could use events. The events are visible on chain. Or you could use a forked network locally and see the console.logs there. Hope it help

2

Use Events for that.

contract BookStore {

event Hello(string indexed bello);

function hello() external {
emit Hello("bello");
}  

}

For more info about the events read this: https://github.com/CJ42/All-About-Solidity/blob/master/articles/Events.md

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.