Ethereum lets people create money that can do things by itself. This means money can follow rules automatically without needing a person to control it.
0
0
Why Ethereum enables programmable money in Blockchain / Solidity
Introduction
You want to make a digital contract that pays money only when certain things happen.
You want to build a game where players earn and spend digital money automatically.
You want to create a system where money moves between people without a bank.
You want to make a savings account that gives interest based on rules you set.
You want to build a voting system where votes are counted and rewarded with tokens.
Syntax
Blockchain / Solidity
contract MyContract {
// code that controls money and rules
}Ethereum uses smart contracts which are like computer programs that run on the blockchain.
These contracts can hold and send digital money automatically based on code.
Examples
This contract lets the owner send money to others following the rules coded inside.
Blockchain / Solidity
contract SimpleWallet {
address owner;
constructor() {
owner = msg.sender;
}
function sendEther(address payable to, uint amount) public {
require(msg.sender == owner, "Only owner can send");
to.transfer(amount);
}
}This contract holds money until a certain time, then lets anyone withdraw it.
Blockchain / Solidity
contract TimeLock {
uint unlockTime;
constructor(uint _unlockTime) {
unlockTime = _unlockTime;
}
function withdraw() public {
require(block.timestamp >= unlockTime, "Too early to withdraw");
payable(msg.sender).transfer(address(this).balance);
}
}Sample Program
This simple contract acts like a piggy bank. Anyone can send money to it, but only the owner can take it out.
Blockchain / Solidity
pragma solidity ^0.8.0; contract PiggyBank { address public owner; constructor() { owner = msg.sender; } // Function to receive money receive() external payable {} // Owner can withdraw all money function withdraw() public { require(msg.sender == owner, "Only owner can withdraw"); payable(owner).transfer(address(this).balance); } }
OutputSuccess
Important Notes
Smart contracts run exactly as programmed without downtime or interference.
Once deployed, contracts cannot be changed, so code must be tested carefully.
Ethereum uses its own digital money called Ether to pay for running contracts.
Summary
Ethereum lets money follow rules automatically using smart contracts.
This makes money programmable and able to do tasks without middlemen.
Smart contracts are the key to creating programmable money on Ethereum.