Introduction to decentralized crowdfunding contract 'FundMe.sol', allowing users to send native blockchain cryptocurrency, with the owner being able to withdraw the funds. The lesson covers deploying on a testnet and handling transactions in Ethereum, Polygon, or Avalanche.
function fund() public payable{...}
Just as wallets hold funds, contracts can serve a similar role. Following deployment, a contract behaves almost identically to a wallet address. It can receive funds, interact with them, and as seen in our demo, the contract can amass a balance akin to a wallet.
msg.value
require(msg.value > 1 ether, "Didn't send enough ETH");
we can use (Ethereum Unit Converter)[https://eth-converter.com/] to convert
If a user attempts to send less than the required amount, the transaction will fail and a message will be displayed. For instance, if a user attempts to send 1000 wei, which is significantly less than one ether (1 x 10^18 wei), the transaction will not proceed.
Understanding Reverts and Gas in Ethereum Blockchain
Reverts can at times be confusing and appear tricky. A revert, in essence, undoes previous actions, sending back the remaining gas associated with that transaction.
If a transaction reverts, it undoes its previous actions and is considered a "failed transaction". But remember, if you initiate a reverted transaction, you still consume gas.