DIGITALAX
Search…
Engineering
DIGITALAX is an incredibly unique NFT, digital fashion and web3 metaverse enabling project because unlike so many teams and companies in this space, we prize putting engineering first.
None of this would be made possible without the incredible work ethic, ethos and continuous dedication of our extraordinary in-house devs. Many of you may not realise just how much goes into building out the DIGITALAX ecosystem. Nothing we deploy is a simple feat. In fact, our devs work around the clock, 8 days a week, 36 hours a day. If you don’t believe me I’ve got the git commits to prove it!

They are truly Metaverse Engineers. The real deal.

Implementation of the First Ever Multi-Token Bridge between Mainnet and Polygon (Matic Network).

DIGITALAX has implemented the first ever multi-token bridge Mainnet and Polygon (Matic Network). This includes the ability to move both a Parent 721 token and its Child 1155 material NFT components to Mainnet from Matic. With this, we have implemented the first ever ERC-998 variant bridge. A major engineering milestone for not just the DIGITALAX team, but rather the broader Web3, Ethereum and Matic community.
DIGITALAX Garment NFT’s are more complex than standard ERC721 tokens. From the beginning we have pioneered a variant of the ERC-998 standard where each 721 ‘Parent’ NFT includes a collection of 1155 ‘Child’ NFTs. Thus, the metadata is much more complex and also holds the Primary Sale Price in ETH, which is used by our staking pool to calculate rewards, and thus isn’t naturally compatible with a simple transfer from Matic.

Layer 1 Mainnet Bridge to Layer 2 Matic

In the case of the Layer 1 Mainnet Bridge, we use the Matic Network SDK protocol to move these tokens between networks. This works by where a user approves the Matic Network contracts to move their token on their behalf. They start a “Deposit” to Matic network, locking the token (721 + 1155s + all metadata) into Polygon’s contract on Mainnet until some future date where it is withdrawn back from Matic network. When this deposit is called on Mainnet it takes approximately 10 minutes for the request to move through Polygon’s protocol and then push to the Matic network. This calls the deposit function on the new DigitalaxGarmentNFTv2 contract and thus mints on the Matic network under the same token ID. Where things become more complex is that the deposit call is not able to move metadata for our specific contract set. For this reason, we have introduced the DigitalaxRootTunnel on Mainnet. Using this contract, any person can call transferNFTsDataToMatic with the appropriate token IDs. This will move the metadata from Mainnet to Matic through the Child — Root Data Tunnel Protocol offered by Polygon. This may need to be manually done by users who move tokens that were originally minted on the Matic network and were bridged into Layer 1 Mainnet (more details to follow on this). But initially, DIGITALAX will be taking care of moving this metadata manually on behalf of the User from Layer 1 to Layer 2 so that users that purchased Garment NFT’s on Layer 1 Mainnet need not worry about migrating their metadata. Note, that tokens with child NFTs on Layer 1 will not move their child NFTs to Layer 2, as the 1155 Layer 1 Materials NFT cannot be removed from the token without burning the master 721. Layer 1 minted tokens can be identified by their token IDs. In order to bridge these tokens back to Mainnet a user will be able to interact with our front end and call the standard withdraw function. This withdrawal function is first called on Matic Network, where the transaction information is stored on our backend, allowing us to display the transaction through the web interface so that the user can more actively maintain oversight of the state of the transfer. Withdrawal to Mainnet takes around 3 hours, and once this time has passed users are able to withdraw through the web interface opening a Mainnet transaction. This transaction will move the same token back to Mainnet, where it is withdrawn from Polygon’s lock and sent directly to the user’s wallet.

Layer 2 Matic Bridge to Layer 1 Mainnet

The most challenging component of the bridge was due to the fact that the L1 contract on Mainnet could not be modified and thus we had to develop a work-around using the DigitalaxRootTunnel Protocol. After a token is minted on Layer 2 Matic Network, it will have a distinct token ID that starts at a higher number vs the Layer 1 Mainnet counterparts. A user that purchases an NFT in our future Matic network sales, or upgrades their existing Matic V1 NFT, will experience this. Take note that in order for our bridge to be successful, we needed the user interface to be as similar as possible for the two types of tokens (L1 and L2). The difference here between Layer 1 and Layer 2 minted tokens is purely the withdrawal to Mainnet functionality. Once a Layer 2 Matic network minted token is on Layer 1, it behaves as if it was minted and originally purchased on Layer 1! For more insight into the workings of this process; after deciphering the token IDs there are different transactions for Layer 1 Minted and Layer 2 Minted tokens. In both cases however, the token is effectively burned in order to move across the networks. For Layer 1 minted, we use the typical withdrawal function as mentioned previously. For Layer 2 Matic network minted tokens, we use the new sendNftsToRoot functionality. This is the only scenario that the ERC998 Parent/Child sets are bridged together, which is completed as the Parent and Child tokens are burned in the process. So essentially, sendNftsToRoot takes advantage of the abi.encode functionality in solidity to create a message about the NFTs being burned. For a batch set of NFTs we save a message for each token in the batch which includes information such as the primary sale price in ETH, associated Child Tokens along with URIs and 1155 amounts, the garment designer address, owner, and parent token URIs. This “message” acts as a ticket on the Mainnet for effectively minting the tokens to the owner. We are take advantage of Polygon’s L1 <> L2 mapping protocol through the Root tunnel and Child Tunnel to move the message about the minted tokens from one network to the next. After a certain period of time, Polygon will move this bytes message onto Mainnet. The user themselves or any other account at this time can submit the bytes message through the DigitalaxRootTunnel contract on Mainnet, this will mint the tokens on Mainnet for the owner that burned them through sendNftsToRoot on the Matic network. On the web interface, this will be a withdraw button that shows up equally for Layer 1 and Layer 2 minted tokens in the withdrawals table. Once the originally Matic Network minted token arrives at Layer 1, it will act as if it had been minted and originally purchased on Layer 1, with a Layer 1 formatted token ID. The protocol described above is highly innovative. It is a multi token protocol bridge that has been designed specifically to allow users to purchase their tokens efficiently on Matic network Layer 2 and bridge them to Mainnet as they wish. During this period we have added a suite of unit tests and rigorous testing scenarios to make sure that the bridge is a smooth user experience and can be leveraged by the wider Ethereum, Matic and Web3 developer community. See the open sourced bridge contracts here and here.
Last modified 2mo ago