A brief exercise to create an NFT-like object in TypeScript (or JavaScript).
This exercise is designed to allow you to show in under an hour:
- you write readable, maintainable code
- you can implement a simply specified system
- you're comfortable with typed code (optional)
If you're new to Blockchain and NFTs, you might find it interesting!
- Clone this repository
- Install the dependencies
npm install
[1] - Create a new file
src/nft.ts
[2] - Export a default function of type
NFTCreateFn
- Implement necessary interfaces & types in
src/supporting.ts
- Run the tests to verify your solution
npm test
[3] - Email your solution to careers@medallion.fm
At a basic level, the Ethereum NFT (ERC721) spec allows tracking ownership of distinguishable assets. Each owner is represented by a string address, and each asset by a unique integer.
To complete this exercise you'll create a TypeScript object (or class) which keeps track of assets and their owners, implementing the following methods:
balanceOf
returns the number of assets held by an ownerownerOf
returns the owner of a specific assettransferFrom
transfers an asset from one owner to another
Your solution should take the form of a function which accepts a list of owners and balances to initialise the assets (with sequential, zero-indexed, integer identifiers) and returns an object implementing these methods.
const owners: NFTHolder[] = [["0xAB…CD", 2], …, ["0x12…34", 1]];
We'll check your submission against the provided test suite, which is based
on the comments found in src/supporting.ts
. However, we're looking for a
good approach to the problem, not a perfect solution.
Please send your solution to careers@medallion.fm in whatever form you prefer, just do you best to make it easy for us to access, and parse (no JPEGs!)
While you only need to submit a single .ts
(or .js
) file, we've provided
a basic development environment help make things easier:
src/supporting.ts
predefined types and interfacessrc/nft.spec.ts
a test suite for the exercise.mocharc.json
configuration for running testspackage.json, package-lock.json
development dependenciestsconfig.json
TypeScript configuration for the exerciseREADME.md
the instructions you're reading right now!
- Feel to use another package manager if you'd like
- You can use plain JS, although we'd prefer TypeScript
- Running (and passing) the tests is optional