hashgraph / hedera-smart-contracts

Contains Hedera Smart Contract Service supporting files
Apache License 2.0
37 stars 51 forks source link

Enhancement: Support for Console Logging in Smart Contracts #675

Open mgarbs opened 5 months ago

mgarbs commented 5 months ago

Problem

In the current Hedera Smart Contracts environment, developers face challenges in debugging and obtaining real-time data on chain for development purposes. This issue becomes particularly pronounced when trying to understand the flow of transactions or the state of contracts without a straightforward way to log information.

Valuable community feedback underscores the difficulty in getting data on chain and, although Solidity 0.8 has introduced custom error types for better visibility, the process remains cumbersome. A direct method to log outputs during contract execution, similar to development experiences on other platforms, is lacking, hindering efficient development and debugging. This enhancement is inspired by hardhat's console log library

Solution

To address this gap, integrating a console logging feature for smart contracts within the Hedera ecosystem, would be most helpful. This enhancement would involve:

This feature would significantly improve the developer experience by providing real-time insights into contract behavior and aiding in quick identification and resolution of issues.

Alternatives

The current alternatives involve using custom error types in Solidity 0.8 and above, which requires reverting transactions to output data, or utilizing off-chain logging mechanisms that complicate development workflows. Another alternative is relying on transaction receipts or events for indirect insights, which lacks immediacy and granularity in debugging contexts.

mgarbs commented 5 months ago

@vea-vecturne @littletarzan

vea-vecturne commented 5 months ago

This would really help with debugging smart contracts. I have been using events and the error feature in Solidity 0.8 for debugging. It definitely helps in that you can see results easier, but you have to use the mirror node. It would be valuable if I could see values while debugging and not have to write any code to decode them from the mirror node.