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 ๐
3/ Letโs see an example of a simple game EtherKing that can be broken by a DoS. A goal of the game is to send more Ether to the contract than the previous king; then the former king gets their funds back ๐ธ
4/ Now define the Attack smart contract ๐ฆน๐ฝโโ๏ธย The contract doesnโt have a fallback function, so any attempt to send the Ether back will fail ๐ธ
5/ Letโs try it out! Deploy KingOfEther then set value to 1 Ether and click โclaimThroneโ ๐ย We can see that the king is the account address we used to claim the throne ๐
6/ Now change the account address and deploy the Attack contract ๐บ
7/ Set the value to 2 Ether and claim the throne again! Now the balance is 2 Ether king is the Attack ๐บ
8/ Finally try to beat the Attack and get the crown back. Change the account again and set value to more than 2 Ether. Click claim the throne function and weโll get an error ๐
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.