A programming language used by Ethereum to implement Smart Contracts. Runs on the Ethereum Virtual Machine.
- Statically Typed
- Compiled
Boilerplate
pragma solidity ^0.8.26;
contract Counter {
uint256 public count;
// Function to get the current count
function get() public view returns (uint256) {
return count;
}
// Function to increment count by 1
function inc() public {
count += 1;
}
// Function to decrement count by 1
function dec() public {
// This function will fail if count = 0
count -= 1;
}
}
Development Process
- Define a contract in the
/contracts
folder - Compile the contract with
truffle compile
- Define a migration in the
/migrations
folder - Ensure
truffle-config.js
is properly defined - Migrate with
truffle migrate --reset
Concepts
- Solidity Contract
- Solidity Migration
- Solidity Struct
- Solidity Map
- truffle-config.js
- truffle console
- solc