DEV Community

Cover image for Mastering Blockchain Development: From Solidity Comments to Forks
Shish Singh
Shish Singh

Posted on • Updated on

Mastering Blockchain Development: From Solidity Comments to Forks

Blockchain technology, with its decentralised and secure nature, has emerged as a game-changer across industries. To truly harness its potential, it's essential to dive deeper into some advanced concepts. In this blog, we'll explore Solidity comments, DApps, Merkle Trees, Hard Forks, Soft Forks, External and Payable functions in the world of blockchain development.

Commenting in Solidity

Comments in Solidity, the programming language for Ethereum smart contracts, serve to enhance code readability and provide essential documentation for developers. There are three main types of comments:

Single-Line Comments: These start with "//" and are used for brief explanations on a single line.

// This is a single-line comment

Enter fullscreen mode Exit fullscreen mode

Multi-Line Comments: Enclosed in "/* */," these are ideal for more extensive explanations or disabling blocks of code.

/*
  This is a multi-line comment
  It can span several lines
*/
Enter fullscreen mode Exit fullscreen mode

@notice Natspec Comments: Special comments recognised by Ethereum clients. They provide descriptions for functions and variables, making it easier for users and developers to understand their purpose.

/// @notice This function does something important
function doSomething() public { ... }

Enter fullscreen mode Exit fullscreen mode

DApp (Decentralized Application)

DApps are applications that run on a blockchain network rather than a centralized server. They leverage smart contracts for their logic, providing transparency, security, and trust to users. DApps come in various forms, from financial services like DeFi platforms to gaming and social applications.

Merkle Tree

A Merkle Tree is a fundamental data structure in blockchain technology. It's used to efficiently verify the integrity of data within a block. Each leaf of the tree represents a piece of data (e.g., transactions), and the nodes above them contain cryptographic hashes of their children. This structure allows for quick and secure verification, making it a key component of block validation.

Hard Fork and Soft Fork

Hard Forks and Soft Forks are methods to introduce changes or upgrades to a blockchain's protocol.

Hard Fork: A hard fork is a significant and backward-incompatible change to the blockchain's protocol. It results in a permanent split in the blockchain, creating two separate chains. Users must update their software to remain on the new chain. Classic examples include the Ethereum and Bitcoin hard forks that gave birth to Ethereum Classic and Bitcoin Cash, respectively.

Soft Fork: A soft fork is a backward-compatible change to the protocol, meaning older nodes can still validate new transactions and blocks. This is achieved by making the rules more restrictive. While soft forks don't result in a chain split, they still require network consensus for implementation.

External Functions

In Solidity, functions can have different visibility levels. "External" functions can be called from outside the contract, typically by other contracts or external actors. They are essential for contract interoperability and communication with the broader blockchain ecosystem.

function externalFunction() external { ... }

Enter fullscreen mode Exit fullscreen mode

Payable Functions

"Payable" functions in Solidity enable contracts to receive Ether (cryptocurrency on the Ethereum network). These functions are commonly used for accepting payments or donations.

function receivePayment() payable public { ... }

Enter fullscreen mode Exit fullscreen mode

Access Modifiers

Access Modifier Visibility Accessible From Gas Consumption
public Public Everywhere Low (read)
private Private Current Contract Low (internal)
internal Internal Current & Derived Contracts Low (internal)
external External External Calls Moderate
view Public Everywhere Low (read, no state change)
pure Public Everywhere Low (no state access)

Visibility: Specifies where the function or state variable can be accessed.

Accessible From: Specifies whether the element can be accessed internally within the current contract, from derived contracts, or externally from other contracts or EOAs.

Gas Consumption: Indicates the typical gas consumption for calling the function. view and pure functions are gas-free when called externally, while other functions have gas costs associated with their execution.

Conclusion

Blockchain development is a dynamic and evolving field, offering a wide range of opportunities for innovation. By understanding Solidity comments, DApps, Merkle Trees, Hard Forks, Soft Forks,Access Modifiers, External and Payable functions, developers can navigate this exciting landscape with greater proficiency and contribute to the growth of the blockchain ecosystem. Stay curious and keep exploring these advanced concepts to unlock the full potential of blockchain technology.

References

Cover: https://www.bairesdev.com/blog/why-use-solidity-for-blockchain-development/

Connects

Check out my other blogs:
Travel/Geo Blogs
Subscribe to my channel:
Youtube Channel
Instagram:
Destination Hideout

Top comments (0)