CTFs

Here is a collection of CTFs shared on Twitter. Make sure you click on Answer whenever you`re ready to give your response or find out the solution.

Calyptus


This contract is intended to allow the deployer to load some ETH into the contract during deployment and later call the sendEther() function to send 1 ETH from the contract to any specified address. However, there is an error in the code. Find the error.ChallengeAnswer
This contract implements a lottery system where users can register by paying 1 ETH each, and the owner can choose a winner and transfer the lottery amount. What's wrong with deploying it on the mainnet?ChallengeAnswer
An old man has stored his wealth in this smart contract and revealed the secret password to his grandson to unlock the funds. The grandson is just about to transfer the ETH to his own account by calling inherit(). How would you hack this?ChallengeAnswer
The following smart contract allows anyone (except a smart contract) to be a member of a club by calling the register() function from their wallet address. How would you make a smart contract register itself as a member?ChallengeAnswer
The following example can't be exploited following a basic re-entrancy approach. Why is this so? Can you think of any option to leverage this scenario?ChallengeAnswer
You're selling an NFT collection of 100 NFTs. 10 users are whitelisted to mint it in the 1st day (presale). Everyone else can buy after 1 day (86400 sec) has passed. Which of these functions would you use in your smart contract for NFT minting and why?ChallengeAnswer
You've created this smart contract to save some of your money in it and withdraw it at least after 10 days. You used compiler version 0.7.0. Two days after depositing, you got an urgent need for money. Is there a way you can get your money right now?ChallengeAnswer
In what slot is the variable 'isPassed' stored? How would you re-arrange these variables in an ideal scenario? Explain.ChallengeAnswer
Explain the vulnerability in the following smart contract.ChallengeAnswer
Which among the following modifiers 'onlyOwner1()' and 'onlyOwner2()' is more gas efficient way of writing modifiers? Why?ChallengeAnswer
The following smart contract allows anyone to be a member of a club by calling the register() function from their wallet address. It prohibits smart contracts from registering as members. How would you make a smart contract register itself as a member?ChallengeAnswer
An old man has stored his wealth in this smart contract and revealed the secret password to his grandson to unlock the funds. The grandson is just about to transfer the ETH to his own account by calling inherit(). How would you hack this?ChallengeAnswer
You're selling an NFT collection of 100 NFTs. 10 users are whitelisted to mint it in the 1st day (presale). Everyone else can buy after 1 day (i.e. 86400 sec). Which of the following functions would you use in your smart contract for NFT minting and why?ChallengeAnswer
Identify the error in the following contract.ChallengeAnswer
How many errors can you find in the following smart contract?ChallengeAnswer