NFT project for LETTERs and WORDs (ERC721). Inspired by LOOT, LootLoose and Blockheads.
Currently configured for Ropsten test network. An interface (/interface
) to mint and call contract functions is accessible from https://letters-words.vercel.app/. This interface requires MetaMask.
This project is meant to demonstrate interchangable/composable ERC721 LETTER
and WORD
contracts.
LETTER
is a simple enumerated ERC721 contract with two custom functions: tokenURI
and claim
. There exists 100 of each latin lowercase letter (a...z) available to claim.
Ropsten address: 0x746F97D9BaF77A026AAF00040178bC12493c6Cd5
The tokenURI
function generates a Base64 JSON load with a unique name
identifier, the corresponding letter
, and a generated SVG image
based on the LOOT contract.
The claim
function allows minting of LETTER
s. tokenId
s correspond to latin letters direction in a repeating fashion:
tokenId | letter |
---|---|
1 | a |
2 | b |
... | ... |
26 | z |
27 | a |
28 | b |
... | ... |
2599 | y |
2600 | z |
Using the standard safeTransferFrom
function to send a LETTER
to the WORD
contract address will mint and assign a new WORD
to the sender containing the LETTER
. See Word for more details on the contract.
WORD
is a more complicated enumerated ERC721 and ERC721Holder which is composed of LETTER
s. Each token can contain up to 5 LETTER
s, with functions to addLetter
, popLetter
and convert a letterToWord
.
Ropsten address: 0x6b81dBA50F7DEcD088dE06F588E9cBd1Afb9CED9
The addLetter
function takes an existing LETTER
NFT and creates a new WORD
composed of only that letter. The function transfers the LETTER
to the contract address, and adds it to a mapping of WORD
token IDs to dynamic arrays of LETTER
IDs. In order to limit on-chain data and gas costs the limit of letters per WORD
is 5. Upon adding a 6th LETTER
the first LETTER
to be added is popped and transferred to the sender, and the new letter is added to the end of the WORD
.
This function pops the last letter in the WORD
and sends the token to the designated _sender
address. If the WORD
only contains 1 LETTER
upon popping, the WORD
token is burned.
Similar to performing a safeTransferFrom
of a LETTER
to the WORD
contract address, this function performs the same transfer and mints a new WORD
owned by the sender.
The interface in the repository is a simple javascript application to allow for UI interaction with the LETTER
and WORD
contracts. The interface utilizes web3.js
for contract interaction. After contract function calls you will need to wait for the transaction to complete then refresh to see changes reflected.
These contracts have not been audited nor extensively tested. It should not be deployed the the mainnet.
- Write unit tests
- Extend interface