A comprehensive guide to deploying your first smart contract on Nexus Layer 1
“If this happens, then do that” — enforced by code and trustless infrastructure.Smart contracts are important because they eliminate the need for intermediaries, reduce the risk of fraud, and ensure agreements are executed exactly as written — with transparency and automation. This makes them a foundational building block for decentralized applications (dApps), enabling trustless interactions in finance, governance, identity, and beyond.
// SPDX-License-Identifier: MIT
: Specifies the licensepragma solidity ^0.8.0
: Specifies the Solidity versionuint256 private storedData
public
, private
, or internal
event DataStored(uint256 newValue)
constructor() { storedData = 0; }
public: Can be called by anyone
private: Can only be called within the contract
view: Doesn't modify state
pure: Doesn't read or modify state
hardhat.config.js
which will define the network configuration, RPC endpoint for Hardhat to connect to, and chainID for signature verification:
.env
in your project root directoryhardhat.config.js
if not already present:contracts/Lock.sol
:
This contract is the default Solidity example included when you scaffold a new Hardhat project. It demonstrates core Ethereum concepts like sending and holding ETH, working with block.timestamp
, using events, and enforcing access control with msg.sender
.
The contract implements a simple timelock wallet. When deployed, it requires:
unlockTime
(timestamp),payable
constructor).owner
) can withdraw the funds. The withdraw()
function will revert if called too early or by anyone other than the owner.
This type of contract is useful for:
scripts/deploy.js
:
A deployment script is a programmatic way to deploy your smart contracts to a blockchain using Hardhat. Instead of manually interacting with the network through a UI or console, deployment scripts allow you to:
unlockTime
)await
contracts/
: Contains your Solidity smart contractsscripts/
: Contains deployment and interaction scripts.env
: Stores your private key and other sensitive datahardhat.config.js
: Configures your development environmentpackage.json
: Manages your project dependencies