Skip to content

Tech interview smart contracts coding problem in Solidity

Notifications You must be signed in to change notification settings

nayms/smart-contracts-tech-interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tech interview smart contracts coding problem

This is a Solidity coding problem for Nayms tech interviews. It is designed to take no more than a few hours.

Getting setup

Ensure you have installed:

  • NodeJS 14+
  • Yarn (install using npm i -g yarn)

Instructions

Part 1: Setup

Clone the repo locally and install the NPM dependencies using:

yarn

Part 2: Complete the task

This part must be completed successfully.

The contracts consist of a mintable ERC-20 Token (which is similar to a Wrapped ETH token). Callers mint tokens by depositing ETH. They can then burn their token balance to get the equivalent amount of deposited ETH back.

In addition, token holders can receive dividend payments in ETH in proportion to their token balance relative to the total supply. Dividends are assigned by looping through the list of holders.

Dividend payments are assigned to token holders' addresses. This means that even if a token holder were to send their tokens to somebody else later on or burn their tokens, they would still be entitled to the dividends they accrued whilst they were holding the tokens.

You will thus need to efficiently keep track of individual token holder addresses in order to assign dividend payouts to holders with minimal gas cost.

For a clearer understanding of how the code is supposed to work please refer to the tests in the test folder.

You only need to write code in the Token.sol file. Please ensure all the unit tests pass to successfully complete this part.

Part 3: The interesting part - BONUS!

This is for bonus points.

The dividends payment process requires looping through token holders. If the no. of holders is very large (e.g. >1000) it's likely that the recordDividend() method will fail (due to out-of-gas error). Come up with another way of paying dividends that does not suffer from this issue.

Outline in writing (or code!) how you would do things differently. Create a Token2.sol file with your new code and add a new token2.test.js test file if you like.

Part 4: Send us your code

Please publish your code to a new private Github repository and give us (@hiddentao, @melks, @tgeorgas) read-only permissions to it.

Commands

  • yarn devnet - run a local ganache instance to deploy the contracts to (we recommend keeping this running form the start in a separate tab)
  • yarn compile - compile the code
  • yarn test - run the tests
  • yarn deploy - deploy compiled code to local testnet (in case you want to use Remix, etc)

License

MIT