Contract Method

In the following code snippet, methods and properties are grouped into three categories:

Public:

These are the primary methods users interact with through transactions. They are named normally.

Private:

Intended for internal use only and accessible for testing. They start with an underscore (”_”).

Single Node Call (SNC):

Executed only on a single node, without creating a blockchain transaction. They start with a double underscore (”__”).

Similarly, properties follow the same naming conventions. However, most interactions happen through methods (endpoints) rather than properties.

var CRC_Contract = {
  method1: function(param1, param2){ ... },   // Public method
  _method2: function(param1, param2){ ... },  // Private method
  __method3: function(param1, param2){ ... }  // SNC method
};

Single Node Call (SNC) methods are key in retrieving data (e.g., wallet balance) without altering the blockchain state. SNCs should never modify contract state, ensuring consistency and reliability. While Hyper Code enforces this, adhering to best practices prevents potential inconsistencies.

Examples

Transaction (Modfiying State)

CRC_Contract.TransferFunds("0x00023...40e20asd", 100);

SNC (querying balance)

CRC_Contract.__BalanceOf("0x00023...40e20asd");

SNCs incur gas fees but are cheaper than transactions. In the next tutorial, we’ll create and deploy your first smart contract, with debugging tips along the way.

Last updated