Anna Kondratenko ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป Profile picture
๐Ÿค– Self-studying AI, Big Data, Data Science โ€ข TensorFlow, Scikit-learn, Keras, Python โ€ข @numerai newbie โ€ข #100DaysOfCode #100DaysOfDefi challenges โ€ข

May 27, 2022, 9 tweets

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.

Keep scrolling