๐Ÿ”ฎ
Solidity
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โ€‹
โš ๏ธ Big numbers are stored as objects: 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!
Copy link