hedera-smart-contracts icon indicating copy to clipboard operation
hedera-smart-contracts copied to clipboard

Enhancement: Support for Console Logging in Smart Contracts

Open mgarbs opened this issue 1 year ago • 3 comments

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:

  • Introducing a console logging library or utility that can be imported into Hedera smart contracts.
  • Allowing developers to insert console.log calls within their contract code to print messages or variable values to the console during execution.
  • Ensuring compatibility with existing Hedera tools and nodes to display these logs in a developer-friendly manner, facilitating easier debugging and development workflows.

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 avatar Feb 13 '24 20:02 mgarbs