description |
---|
Solidity is the main smart contract language of Ethereum. Learn it well and forge your destiny. |
In this Solidity section, we present you with some tips and learning material to get you on the path of confidently developing smart contracts and deploying them to your network of choice.
📕 Read the docs: https://docs.soliditylang.org
📚 Go through each topic from solidity by example editing YourContract.sol
in 🏗 scaffold-eth
📧 Learn all the Solidity globals and units
👨🏫 Start super simple with a counter: uint8 public count = 1;
⬇️ Then a function dec() public {}
that does a count = count - 1;
🔬 What happens when you subtract 1 from 0? Try it out in the app to see what happens!
🚽 UNDERFLOW!?! (🚑 Solidity >0.8.0 will catch this!)
🧫 You can iterate and learn as you go. Test your assumptions!
🔐 Global variables like msg.sender
and msg.value
are cryptographically backed and can be used to make rules
📝 Keep this cheat sheet handy
⏳ Maybe we could use block.timestamp
or block.number
to track time in our contract
🔏 Or maybe keep track of an address public owner;
then make a rule like require( msg.sender == owner );
for an important function
🧾 Maybe create a smart contract that keeps track of a mapping ( address => uint256 ) public balance;
🏦 It could be like a decentralized bank that you function deposit() public payable {}
and withdraw()
📟 Events are really handy for signaling to the frontend. Read more about events here.
📲 Spend some time in App.jsx
in packages/react-app/src
and learn about the 🛰 Providers
formatEther
and parseEther
(ethers.js) will help with WEI->ETH and ETH->WEI.
🧳 The single page (searchable) ethers.js docs are pretty great too.
🐜 The UI framework Ant Design
has a bunch of great components.
📃 Check the console log for your app to see some extra output from hooks like useContractReader
and useEventListener
.
🏗 You'll notice the <Contract />
component that displays the dynamic form as scaffolding for interacting with your contract.
🔲 Try making a <Button/>
that calls writeContracts.YourContract.setPurpose("👋 Hello World")
to explore how your UI might work...
💬 Wrap the call to writeContracts
with a tx()
helper that uses BlockNative's Notify.js.
🧬 Next learn about structs in Solidity.
🗳 Maybe an make an array YourStructName[] public proposals;
that could call be voted on with function vote() public {}
🔭 Your dev environment is perfect for testing assumptions and learning by prototyping.
📝 Next learn about the fallback function
💸 Maybe add a receive() external payable {}
so your contract will accept ETH?
🚁 OH! Programming decentralized money! 😎 So rad!