Smart contracts are self-executing contracts with the terms of the agreement directly written into code. They run on blockchain networks like Ethereum.
// Simple Storage Contract Example
pragma solidity ^0.8.0;
contract SimpleStorage {
uint storedData;
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint) {
return storedData;
}
}
Key characteristics of smart contracts:
Let's interact with a simulated smart contract. This contract stores a number that anyone can update.