
Seamlessly Bridging Web2 and Web3: Asset Import-Export in MightyNet
The landscape of digital asset management has experienced a paradigm shift with the advent of blockchain technology. The ability to create, manage, and transfer digital assets in a decentralized, immutable, and transparent manner has opened up a plethora of opportunities for businesses and users alike. At MightyNet, we have embraced this revolution and developed a robust system that facilitates the fluid import-export of off-chain assets, thereby enriching our Web3 ecosystem of apps and games.
In this article, we will delve into the technical aspects of how our import-export system works, offering a behind-the-scenes look at how we manage assets in the MightyNet ecosystem.
Why On-chain and Off-chain Assets?
When we set out to build MightyNet, one of our primary objectives was to optimize the player experience while ensuring the efficient use of blockchain technology. By making it possible for assets to exist both on-chain and off-chain, we have managed to strike a balance that allows us to deliver complex game features without burdening the players with constant gas costs. Here are the key reasons why we opted for this hybrid approach:
- Gas-Free Complex Features: One of the major advantages of off-chain assets is the ability to implement complex features without incurring gas costs. For instance, our crafting system, which is heavily dependent on asset ownership and modifies these records, operates off-chain. If we were to implement this feature solely on-chain, players would have to bear gas costs each time they crafted an item. By managing these assets off-chain, we can offer a smooth, uninterrupted gaming experience.
- Enhanced Metagame Potential: The decision to include off-chain assets also opens up vast possibilities for implementing additional metagame features. By shifting these features off-chain, we can add depth and complexity to our games without requiring players to pay gas costs each time they engage in these elements. This gives us the freedom to innovate and expand our gaming universe without imposing additional financial burdens on our players.
In summary, combining on-chain and off-chain assets allows us to leverage the best of both worlds: the security and transparency of blockchain technology, and the flexibility of traditional Web2 systems. As we continue to evolve our MightyNet ecosystem, we are excited about the opportunities this dual approach offers us to enhance our gaming experiences while maintaining the core benefits of blockchain technology.
Exporting and Importing MightyNet Assets
Exporting and importing can mean different things depending on the asset being exported. We currently support two kinds of assets — fungible and non-fungible. Right now, fungible assets are P.A.R.T.S, Supply Crates, and Blueprints while Gadgets are the only non-fungible assets.
To avoid taking custody of the assets when they are imported, we implemented a system where assets are never held in a separate wallet but still make them unavailable on-chain. How we do these for each kind of asset is as follows:
Fungible
- Assets, when exported, are minted to an ERC1155 contract.
- When imported, the amount is burned from the contract.
Non-fungible
- Assets, when exported the first time, are minted to an ERC721 contract.
- When importing assets, they are restricted from being transferred. They stay in the user’s wallet but will be unable to be transferred.
- When these assets are exported again after the first time, they are not re-minted but are instead just unrestricted; enabling standard trading as per the usual ERC721 contract.
- The restriction is handled through our own MightyNetERC721RestrictedRegistry contract. This is also the same method and contract we use to enable the linking of our Ethereum Mainnet NFTs without transferring them to a holder contract.
Exporting Assets from the MightyNet
The journey of an asset begins off-chain within the MightyNet ecosystem. Here’s a step-by-step breakdown of the export process:

- Asset Creation: The asset and its ownership are first recorded in a Web2 database.
- Export Request: The export is initiated by calling our dedicated contract's ‘export request’ function. The export request function requires an export fee, which is an estimate of the gas cost that the actual export would incur.
- Export Request Emission: Upon successful execution of the function, an event is emitted. This event is picked up by our proprietary backend service, the Blockchain Reader (BR).
- Export Request Forwarding: The BR forwards the export request to another backend service, the inventory service, which performs a series of checks. It verifies if the asset is exportable and whether the user owns the asset or has a sufficient quantity for the export request.
- Actual Export: Once all checks pass, the inventory service calls upon the Blockchain Writer (BW) to initiate the actual export transaction. The export fee paid by the user is used for the transaction.
- Asset Minting: The BW calls the ‘export’ function on the MightyNetTerminal contract that then mints/unrestricts the asset on its corresponding MightyNetAsset contract.
- Export Emission: Upon successful minting/unrestricting, the MightNetTerminal emits an event that the BR also picks up.
- Database Update: The BR then sends this confirmation to the inventory service which then removes the exported assets from the off-chain database, completing the export process.
Importing Assets to the MightyNet
Only MightyNet assets can be imported into the MightyNet:

- Import Request: Just like exports, users can initiate the import of on-chain assets through the MightyNetTerminal contract. The process starts by calling the ‘import’ function on our contract. Unlike the export process, no import fee is required. Users only need to cover the gas cost for executing the import function.
- Asset Burning: Upon calling the import function on the contract, the assets will then be burned/restricted on its MightyNetAsset contract.
- Event Emission: After execution of the import function, an event is emitted and caught by the BR.
- Import Request Forwarding: The BR forwards the import request to the inventory service. The service conducts checks to verify if the imported asset is supported within the MightyNet ecosystem by checking metadata and registration status in the database.
- Database Update: Once the checks pass, the asset is added to the user’s inventory in our database, marking the completion of the import process.
Handling Failure Scenarios
The Blockchain Reader processes events in the same manner the blockchain executes transactions — they are processed one by one through a queue.
To make sure our off-chain database is never out-of-sync with on-chain assets, the BR implements robust recovery features in case of invalid import or export requests and unexpected errors.
- The BR keeps track of its last processed event. In case of unhandled errors, it will stop processing newer events until the error encountered for that particular event is handled to ensure no event causes the BR to improperly process events.
- In case of unplanned shutdowns or crashes, the BR will fetch all missed events and add them to the front of its event queue. This is done by fetching all events that come after the last processed event.
- For export requests, if the actual export transaction execution by the Blockchain Writer fails, this would also be treated as a failure to process the current event and will stop processing.
At MightyNet, we are committed to pioneering a seamless bridge between Web2 and Web3 worlds, allowing our users to enjoy the best of both. Our asset import-export system exemplifies our dedication to this mission, providing an efficient and user-friendly approach to digital asset management.
Stay tuned for more updates as we continue to innovate and push the boundaries of blockchain technology. Let’s make the future, together.
Seamlessly Bridging Web2 and Web3: Asset Import-Export in MightyNet was originally published in Mighty Bear Games on Medium, where people are continuing the conversation by highlighting and responding to this story.