Skip to content

gingerkeith/CaptureTheEtherHardhat

 
 

Repository files navigation

Capture the Ether with Hardhat

Challenges from Capture the ether on hardhat.

How to use:

  1. Clone this repo.
  2. Complete the challenges on ./test/.
  3. Verify the result running yarn test.

Challenges

  1. Deploy a contract
  2. Call me
  3. Choose a nickname
  4. Guess the number
  5. Guess the secret number
  6. Guess the random number
  7. Guess the new number
  8. Predict the future
  9. Predict the block hash
  10. Token sale
  11. Token whale
  12. Retirement fund
  13. Mapping
  14. Donation
  15. Fifty years
  16. Fuzzy identity
  17. Public Key
  18. Account Takeover
  19. Assume ownership
  20. Token bank

Warmup

The warmup challenges are intended to get you familiar with the way Capture the Ether works and the tools you need to use.

Deploy a contract

To complete this challenge, you need to deploy a new contract on hardhat.

Call me

To complete this challenge, all you need to do is call the function named callme.

Choose a nickname

To complete this challenge you need to track your nickname on the Capture the Ether contract.

Lotteries

Feeling lucky? These challenges will show how hard it is to run a fair lottery.

Guess the number

I’m thinking of a number. All you have to do is guess it.

Guess the secret number

Putting the answer in the code makes things a little too easy.

This time I’ve only stored the hash of the number. Good luck reversing a cryptographic hash!

Guess the random number

This time the number is generated based on a couple fairly random sources.

Guess the new number

The number is now generated on-demand when a guess is made.

Predict the future

This time, you have to lock in your guess before the random number is generated. To give you a sporting chance, there are only ten possible answers.

Note that it is indeed possible to solve this challenge without losing any ether.

Predict the block hash

Guessing an 8-bit number is apparently too easy. This time, you need to predict the entire 256-bit block hash for a future block.

Math

These challenges use a variety of techniques, but they all involve a bit of math.

Token sale

This token contract allows you to buy and sell tokens at an even exchange rate of 1 token per ether.

The contract starts off with a balance of 1 ether. See if you can take some of that away.

Token whale

This ERC20-compatible token is hard to acquire. There’s a fixed supply of 1,000 tokens, all of which are yours to start with.

Find a way to accumulate at least 1,000,000 tokens to solve this challenge.

Retirement fund

This retirement fund is what economists call a commitment device. I’m trying to make sure I hold on to 1 ether for retirement.

I’ve committed 1 ether to the contract below, and I won’t withdraw it until 10 years have passed. If I do withdraw early, 10% of my ether goes to the beneficiary (you!).

I really don’t want you to have 0.1 of my ether, so I’m resolved to leave those funds alone until 10 years from now. Good luck!

Mapping

Who needs mappings? I’ve created a contract that can store key/value pairs using just an array.

Donation

A candidate you don’t like is accepting campaign contributions via the smart contract below.

To complete this challenge, steal the candidate’s ether.

Fifty years

This contract locks away ether. The initial ether is locked away until 50 years has passed, and subsequent contributions are locked until even later.

All you have to do to complete this challenge is wait 50 years and withdraw the ether. If you’re not that patient, you’ll need to combine several techniques to hack this contract.

Accounts

These challenges test your understanding of Ethereum accounts.

Fuzzy identity

This contract can only be used by me (smarx). I don’t trust myself to remember my private key, so I’ve made it so whatever address I’m using in the future will work:

  1. I always use a wallet contract that returns “smarx” if you ask its name.
  2. Everything I write has bad code in it, so my address always includes the hex string badc0de.

To complete this challenge, steal my identity!

Public Key

Recall that an address is the last 20 bytes of the keccak-256 hash of the address’s public key.

To complete this challenge, find the public key for the owner's account.

Account Takeover

To complete this challenge, send a transaction from the owner's account.

Miscellaneous

These challenges defy categorization.

Assume ownership

To complete this challenge, become the owner.

Token bank

I created a token bank. It allows anyone to deposit tokens by transferring them to the bank and then to withdraw those tokens later. It uses ERC 223 to accept the incoming tokens.

The bank deploys a token called “Simple ERC223 Token” and assigns half the tokens to me and half to you. You win this challenge if you can empty the bank.


Built by @SMARX

About

Capture The Ether Challenges with Hardhat

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 51.7%
  • TypeScript 46.6%
  • JavaScript 1.7%