This repo contains answers for a Blockchain Technical Test challenge, as well as the code for the practical excercise (question J
).
Answers for each individual question can be found in the answers directory.
Solidity code for the solution can be found in the contracts directory.
Typescript test code for the solution can be found in the test directory.
Standard Hardhat commands are available.
For the full list of commands please check the package.json file.
npm i
npm run test
npm run coverage
Here's a list of additional restrictions imposed as well as liberties taken for developing the CampaignSale
contract:
- the maximum length for a campaign is exposed as a public constant so users can query it in case a campaign launch reverts with a
campaign length exceeds maximum
error - a campaign cannot be launched with a goal of
0
tokens - a specific
campaign does not exist
error was added to the cancel, contribute to, withdraw from, claim, refund and get campaign functionalities - campaigns are deleted in order to follow the instructions; it would have been preferrable to disable them instead (see here for reasons why)
- a campaign cannot be contributed to or withdrawn from using an amount of
0
tokens - even after a campaign is refunded, the
pledged
field will still record the amount deposited for historical purposes