Elementals Trading

Elementals
4 min readJan 7, 2022

Minting Paths

When I developed the first version of the Elementals smart contract I was going to offer the community the ability to mint the element of their choice. I had developed the website in a way that lets you choose which element path you want to take.

The idea was that if you choose the Fire path and mint 5 Fire Elementals you would unlock the Fire Legendary Elemental. At the time I became a beta tester for Cool Cats’ upcoming Cool Pets launch and that’s where I learned about the Pagzi smart contract optimization.

Cool Cats & Toy Boogers

In the Cool Cats beta discord developers were talking about a new project that launched called Toy Boogers and how they had their smart contract developed by Pagzi Tech who reduced the minting gas fees by over 50%. This was huge and as I found out about it I started looking more into it and seeing how I could apply the innovation to Elementals. I experimented with the optimization and was able to apply it to my smart contract with a caveat — minting would have to be randomized and I could no longer offer element based minting paths.

Community Voting

This was a real dilemna for me I wanted to offer element based minting and also minting optimization to save my community money on gas fees, but I couldn’t have both. Instead of making the difficult decision myself I leaned on my community for a vote posing the question — Would you rather A) Pay regular gas to mint the element of your choice or B) Pay 50% less gas but minting is random? To my surprise it was a 2/3 majority vote in favor of lower gas fees.

It was at that moment that Champ, one of our community members at the time (now a Mod), suggested going with option B if people are willing to trade. This immediately sparked an idea for me, what if we could offer a trading feature on the website where people could perform one for one trades with other community members? I began exploring the idea and developed the architecture diagram for what that could look like.

Trading Architecture

I began to think of all the software pieces we would need to make trading happen. Building a trading API, a database to house the trades, all of the features on the website. I designed this elaborate system with all kinds of moving parts communicating with one another and arrived to my final architecture state.

Discord Trading Channel

It’s funny because the simplest solution was sitting right in front of me. I could save time and offer the trading feature right away by opening a trading channel in our discord. That’s what we did we opened a new trading channel in our discord for people to discuss trades with a few rules:

  • Trades must be agreed upon by both parties
  • Trades are on a first come first serve basis
  • Trades are queued and executed when gas is low

So far we have had one trade agreement executed and two trades in the queue waiting to be executed when gas is low. This was the perfect solution for our circumstances and our members are happy with the trading feature.

Smart Contract Trading

I’m using the OpenSea model for whitelisting trade approvals without requiring our community members to have to pay an approval gas fee. In the Elementals.sol smart contract I require the trading admin account in my constructor as the “systemAccount”.

The systemAccount is then passed to the ERC721P.sol constructor which requires the “systemAccount_” parameter for the trading feature to function.

Finally the “isApprovedForAll” function in the ERC721p.sol file follows the OpenSea model and whitelists the system account for trading (and staking).

That’s it! That’s how to setup a trading admin account and offer your community a trading feature within your discord!

--

--

Elementals

5,000 anime NFTs featuring Earth, Water, Fire, Wind and Lightning characters.