2

The main block of code in Forge's Console.sol is

 address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);

function _sendLogPayload(bytes memory payload) private view {
    uint256 payloadLength = payload.length;
    address consoleAddress = CONSOLE_ADDRESS;
    /// @solidity memory-safe-assembly
    assembly {
        let payloadStart := add(payload, 32)
        let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)
    }
}

I can't seem to find any code at 0x000000000000000000636F6e736F6c652e6c6f67. How does it work?

1 Answer 1

2

The 0x000000000000000000636F6e736F6c652e6c6f67 address is for hardhat local blockchain that we use for testing our contracts locally, in the dev invironment. So, under the hoods, hardhat is sending that log data to a contract of its own, locally, subscribing to the events emitted by that log contract and then showing you the logs in your console.

Logging data for debugging is not supposed to get to testnet or mainnet networks. It's just for use locally in the dev environment.

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.