🔮
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.
👨🏫 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!
🧫 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⏳ 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()
⚠️ Big numbers are stored as objects:
formatEther
and parseEther
(ethers.js) will help with WEI->ETH and ETH->WEI.📃 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...🗳 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.
💸 Maybe add a
receive() external payable {}
so your contract will accept ETH?🚁 OH! Programming decentralized money! 😎 So rad!
Last modified 1yr ago