Reader small image

You're reading from  The Essential Guide to Web3

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781801813471
Edition1st Edition
Concepts
Right arrow
Author (1)
Vijay Krishnan
Vijay Krishnan
author image
Vijay Krishnan

Vijay Krishnan, an experienced expert in blockchain and Web3, holds the position of head of SysOps for Linea, a Layer 2 blockchain at Consensys. With a rich background in blockchain, he's guided Fortune 100 companies from ideation to product build. With over 50 projects and 300+ use cases to his credit, Vijay has left an indelible mark on the industry. Prior to Consensys, he pioneered the AWS Partner Blockchain ecosystem and led IBM North America's Blockchain Practice. With two decades on Wall Street, he possesses deep financial and tech insights. Vijay, a leader and subject matter expert, empowers clients in DeFi, NFTs, gaming, and the metaverse. Beyond work, he's a mentor, speaker, author, and organic farmer. His knowledge and innovation continue to shape the blockchain and Web3 landscape.
Read more about Vijay Krishnan

Right arrow

Writing your first Solidity smart contract

Now that you have installed all the required tools, you can use them to develop your smart contracts. We will write a simple contract to increase and decrease the count stored in the contract.

To create a new Hardhat project, you can run the following commands:

mkdir Countercd Counter
npx hardhat init

Then, choose the following option in the Hardhat menu, and leave all default selections for the prompts:

Create a JavaScript project

These commands will set up the required folder structure and some skeleton code for you to get started. The following figure shows you what to expect when you open the project in VS Code.

Figure 5.11 – A Hardhat example in VS Code

Figure 5.11 – A Hardhat example in VS Code

Your source code will be empty. Now, let us learn what code needs to be placed in these files and folders.

Here is a Solidity smart contract example that allows you to increment and decrement a count stored in the contract:

 // SPDX...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
The Essential Guide to Web3
Published in: Nov 2023Publisher: PacktISBN-13: 9781801813471

Author (1)

author image
Vijay Krishnan

Vijay Krishnan, an experienced expert in blockchain and Web3, holds the position of head of SysOps for Linea, a Layer 2 blockchain at Consensys. With a rich background in blockchain, he's guided Fortune 100 companies from ideation to product build. With over 50 projects and 300+ use cases to his credit, Vijay has left an indelible mark on the industry. Prior to Consensys, he pioneered the AWS Partner Blockchain ecosystem and led IBM North America's Blockchain Practice. With two decades on Wall Street, he possesses deep financial and tech insights. Vijay, a leader and subject matter expert, empowers clients in DeFi, NFTs, gaming, and the metaverse. Beyond work, he's a mentor, speaker, author, and organic farmer. His knowledge and innovation continue to shape the blockchain and Web3 landscape.
Read more about Vijay Krishnan