Day 61 of #100DaysOfDeFI 🚀 Today I learned how to deploy tokens on Ethereum testnet 👾 for this I will use Rinkeby testnet and Remix IDE for developing smart contract 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ Use code from the day 57 of the challenge to create ERC20 tokens 👇
2/ Then, create 2 additional accounts on Rinkeby testnet on MetaMask 🦊 For that, just choose the Rinkeby testnet and click “Create account” 👾
3/ Add the 2 created accounts into the contract so it will mint tokens for them 🪙
4/ Time to deploy the contract 🤖 Make sure, you’re on an account 1 on MetaMask, then select “Injected Web 3”, set a token name and a symbol and click “transact”
5/ Confirm the transaction on MetaMask pop up window and check if the transactions went through successfully ✅ You can see it on etherscan for Rinkeby 👇
6/ Add token to MetaMask 🦊 When you copy the contract address, MetaMask will automatically recognize its name and symbol. Do it for all 3 accounts.
7/ Now you can transfer token between the accounts! 🦾 Copy the account 2 address and with account 1 selected click “Send” 👾 I am sending 10 ANC20 tokens to my account 2 👩🏻💻
8/ Finally, check the account 2 balance: if there are 10 tokens more, the transaction has been successful! 🎉 You can go on testing with account 3 and others accounts 👩🏻💻
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Day 75 of #100DaysOfDeFI 🚀 today 3/4 of the challenge is done! 🎉 Also today I finish exploring Solidity vulnerabilities with learning about Denial of service (DoS) attacks 🦹🏼♀️ #womenwhocode#100DaysOfCode
How it works 🧵
1/ There are many ways to attack a smart contract and at some point create a DoS⚡
2/ Denial of Service attack paralyzes a smart contract and makes it temporarily unusable 🛑
Day 74 of #100DaysOfDeFI 🚀 Today I learned about Delegate Call vulnerability in #Solidity 🦹🏼♀️ When using delegatecall opcode one should be careful because wrong usage will lead to unexpected results ⚠️ #womenwhocode#100DaysOfCode
How it works 🧵
1/ What delegatecall is? When contract A uses delegatecall to call contract B it means that the contract B code will be executed inside context of the contract A: storage, msg.sender, msg.value, msg.data, etc will be the A’s context.
2/ Storage layout must be the same for contract A and contract B → it means both contracts should declare the same state variables in the same order 👾
Day 73 of #100DaysOfDeFI 🚀 Learned about Self Destruct vulnerability in #Solidity 🦹🏼♀️ Selfdestruct deletes the contract from the blockchain and and sends all Ether to a designated address 💸 In some scenarios it can lead to unexpected problems ❌ #100DaysOfCode
How it works 🧵
1/ Let’s see how it works with an example of a simple game 🎲 Players send to the contract 1 token 🪙 the one who deposits the fifth token wins 🏆
Game code 👇
Day 72 of #100DaysOfDeFI 🚀 Today I looked at arithmetic Over/Under Flows in #Solidity 👾 This vulnerability been secured by the current Solidity version 🦸♂️ Nevertheless, it is important to understand what it is and how to avoid it 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ An overflow in Solidity occurs when a number is incremented beyond its maximum value. For example, if we have a uint8 with a value of 255 and increment it by 1, it will “reset” and set a value to 0. Remember, the maximum value for uint8 is 255❗
2/ Similar thing happens when we decrease a value beyond its minimal level. Taking the same example, if a uint8 is set to 0 and we decrease it by 1, it will set to 255, since 0 is the minimal value of uint8❗
Day 71 of #100DaysOfDeFI 🚀 looked at Re-Entrancy vulnerability🦹🏻 It is one of the most destructive attacks in the #Solidity smart contracts 💸 The untrusted contract that exploits the vulnerability is able to drain all user's funds 🚰 #100DaysOfCode
How it works 🧵
1/ To make it happen, there should be 2 contracts: a vulnerable contract and an attacker’s contract 👺
2/ The attacker should deposit some funds into the vulnerable contract 💰
Day 68 of #100DaysOfDeFI 🚀 Today I worked on the Factory smart contract that is a part of the decentralized exchange architecture 💱 Factory creates and keeps track of all Pair contracts 👩🏻💻 #womenwhocode#100DaysOfCode
Summary 🧵
1/ The Factory will include:
🔷 createPair - create a Liquidity Pool;
🔷 adjustAmount - adjust a number of tokens using a formula;
🔷 getReserves - a getter function;
🔷 addLiquidity - add liquidity to the LP;
🔷 removeLiquidity - withdraw liquidity;
🔷 trade1for2 - swap tokens.
2/ First, initialize contract and define the state variables 👩🏻💻