Hyper Code IDE Guide
  • Introduction to Hyper Code IDE
  • Lesson 1: Get Started
    • Smart Contract Project Files
    • Project Files
    • CRC_Contract
    • Contract Method
  • Lesson 2: Smart Contracts
    • Introduction to Smart Contracts
    • Creating your first smart contract
    • Debugging
    • Deployment
    • Smart Contract Interaction
  • Lesson 3: Wallet Access
    • Introduction to Wallet Access
    • Circular Wallet Architecture
    • Native CRC Wallet
    • Custom Wallet Data
  • Lesson 4: Your First Token
    • Introduction
    • Simple Token Balance
    • GetBalance Function
    • Drop Function
    • Transfer Function
Powered by GitBook
On this page
  1. Lesson 2: Smart Contracts

Debugging

PreviousCreating your first smart contractNextDeployment

Last updated 7 months ago

At this point, it’s essential to debug the code and ensure all endpoints meet the required specifications. A good approach is to add all relevant endpoints to the Test.hc file for thorough debugging and validation. The file should follow this structure:

CRC_Contract._constructor();

 CRC_Contract.__HelloWorld();
 CRC_Contract.ChangeNumber(100);
 CRC_Contract.ChangeString("Test"); 
 CRC_Contract.__GetNumberInfo();
 CRC_Contract.__GetStringInfo(); 

By adding these debugging endpoints to the Test.hc file, you can thoroughly test and verify your smart contract’s behavior, ensuring it meets all requirements. To start debugging, click the Debug button in Hyper Code IDE, which will activate the tools needed to validate the contract’s functionality.

After successful execution, you’ll see the Contract State displayed in the IDE’s output window as a JSON string. This includes properties like:

  • _MyString with a value of “test.”

  • _MyNumber set to 100.

  • _StringChanger and _NumChanger showing the wallet addresses of those who made changes.

This JSON output offers clear visibility into your contract’s current state, making it easy to track values and interactions.

After the Contract State, the Contract Output will display the results from various endpoints in your smart contract. This section helps diagnose how endpoints are functioning, allowing you to verify that your contract behaves as expected and provides insights into specific actions within your blockchain application.

After the Contract Output, you’ll find the Execution Performance box, showing how long the contract took to execute. In this case, it reports an execution time of 1,280 microseconds.

At this stage, optimising your code is key. Reducing execution time lowers both gas fees and execution costs, improving your smart contract’s efficiency and cost-effectiveness in blockchain operations.

The debugging button