“ERC721J” A Token For Creators Of Music

Originally published on Medium on May 5, 2022*

In Short

  • ERC721J is a version of the ERC721 built for Creators of music and anyone who prefers a master/copy model of distribution.

  • It lets the artist create an original (1/1) NFT and allow for any edition size.

  • The “pay it forward” mechanic is the first minting mechanic to be featured.

  • Compared to a standard OpenZeppelin ERC721 Enumerable, it uses less gas while having more features.

  • The code is now on GitHub

  • I’d love to help any artists who want to use this contract to mint tokens of their creations. Send me a message!

The 721J contract is a modified ERC721 but includes some special features that are important to me as a musician. This article continues the previous one and goes into more detail about the philosophy and technical aspects.

The creation should have an original of itself. The idea is if you are making something, like music, the original/master is an important distinct thing that the artist creates and holds themselves, something that is imperative for creators.

Edition size is a separate decision. You start with an original 1/1 that you make copies until it reaches the maximum amount of editions.

With this contract, NFTs are only mintable if you already have one, similar to making a copy of a cd or tape for someone. You can also think of it like paying it forward for minting. This is surprisingly simple- with 1 line that checks if the token is in your wallet. Anyone can swap in other minting mechanics, with further options in development for new versions.

Gas is important even though I wasn’t thinking about having a big mint. I’m sure a lot of people have seen the Azuki contract article (editor’s note: you had to be there at the time) and the table below comparing the OpenZeppelin contract to the ERC721A. Trying to keep gas down was a tough challenge, but necessary, given the extra data I was trying to store with each token.

Table comparing the OpenZeppelin contract to the ERC721A (source: Azuki ERC721A article)
Table comparing the OpenZeppelin contract to the ERC721A (source: Azuki ERC721A article)

For the ERC721J, it keeps track of more than just tokenId. There is also a songId for each song and a serial# that corresponds to that. The contract also needs to keep track of the total supply of each individual song. Sounds like a lot more gas, right?

That said, it costs more gas to create an original than it does to make a copy. With all the extra data stored to the blockchain, the cost of minting a copy to a new wallet is just 110k gas. If that wallet already has a token from the contract then it is even cheaper at 93k gas.

This is the gas to mint a copy
This is the gas to mint a copy

Here is an example of how much gas it costs to create an original with 3 rarities. 314k gas! That is a lot compared to a regular ERC721A, but considering you’re setting 3 different tokenURIs in that one transaction, and they’re not regular 721 tokens, it is a wise trade off. This transaction is expensive because it’s storing the full Arweave hash on chain for 3 rarities of one song. This can be improved a lot by creating a manifest on ArDrive. The 40 character strings stored on chain can become 1 character in length if you want to really optimize this part, which lowers gas by almost half.

This is the gas to mint a new original song
This is the gas to mint a new original song

With ERC721J you can keep track of Token Ids, as well as a Song Id and Serial # of each song. This way you can keep track of everything.

When a song is made it creates a new Song Id. There is a counter that makes sure there can only be a maximum number of copies any song. When a copy is made it adds another serial # until the maximum has been reached. Rarity can be split up by serial # of song. Another option would be to treat 1st generation copies and 2nd generation copies as a way to distinguish rarity. 1st gen. being a copy made from the original, and 2nd gen. being a copy of a copy.

What makes this worth a new name?

Because of the new functions that relate to minting copies from an original.

The new functions

The main one is “mintCopyTo”. The other important ones are going to be “mintOriginal” and “mintCopy”.

I’ll explain all of them from my DeSante Records contract for context.

“MintNewSong” makes sense as it’s the function to create a new original but I’ve updated it to be named “mintOriginal” in the ERC721J contract, as it will suit it better for more than music.

In the original contract there are 3 functions to mint copies, ownerMintsCopy, mintCopyTo, and mintCopySong. OwnerMintsCopy I made to bypass the 0.05 minting fee if I was making copies for myself, and mintCopySong was made to save a tiny bit on gas if the copy was minted to the same wallet. In the ERC721J contract, “mintCopySong” is updated to “mintCopy” to go with the better naming.

The most important new function is “mintCopyTo” because it takes a tokenId and address and lets you mint a copy to any wallet. That could mean a copy of an original, or a copy of a copy, from any wallet.

Included in version 2 will be “mintCopy” having the ability to mint direct (traditional minting style). I look forward to talking more about version 2 of the ERC721J token once I get started working on it. I haven’t immediately started working on it because I’m working on something else that directly relates to music NFT framework.

This new project has brought to light the improvements that need to be made with my original contract and shows what was deployed in February will need to be upgraded soon to better suit the needs of a music NFT contract. There will be updates to the GitHub for the ERC721J token as the project develops. The GitHub already has improvements made from the contract deployed in February.

Looking forward.

The first of these improvements is to add a contract URI function. Did you know that contracts don’t have their own URI? Wouldn’t it be nice if contracts had a spot where you could find relevant information? That could be updated periodically by the team, that had important links, info, pictures, etc. The needs of the project that I will write about shortly requires that contracts have badass features like a contract URI. It was 5 lines to add and in hindsight was so obvious how needed it is. Once this new project is at the point that it’s ready to show people, I‘m itching to start v2 of the ERC721J. If you want to stay up to date then follow this Medium page, or follow me on Twitter. I would love to get a community on discord going about music NFTs https://discord.gg/nfWqyAkR2w.

Don’t forget, check out the code on GitHub, tell your musician friends and if you’re an artist who wants to use this contract please let me know! It would be really cool to see other artists use this contract.

Subscribe to Contract Wizard
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.