'Hardhat console log a string and variable in same statement
Is there a way I can log a string and a bytes variable in the same statement using hardhat/console.sol? Or at least have them print on the same line?
In the Hardhat docs it shows that you can add string arguments:
console.log("Changing owner from %s to %s", currentOwner, newOwner)
but is there a way to do this for other kinds of variables?
Solution 1:[1]
There is no overload of log function of hardhat/console.sol contract for (string,bytes,bytes), but there is one for:
function log(string memory p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2));
}
Which means, you can use it like this:
console.log("your format string %s %s", string(yourBytesVariable1), string(yourBytesVariable2));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | keser |
