Ethereum is a large and diverse ecosystem, where different chains provide different advantages, functionalities and use cases. Some chains provide high tps, some provide better data availability, while others provide advantages for specific use cases. Thus, there is a need to reduce the discrepancy in the availability of functionalities and enable them to be cross-chain. Our project is aimed towards tackling this problem.
Firstly, we have specifically tackled the problem of the unavailability of a native Verifiable random function (VRF) in the polygon ecosystem by leveraging the VRF provided by the moonbeam chain. We have extended the native moonbeam VRF to be cross-chain and provide the same functionality in the polygon chain as well. This helps in extending the scope of DApps in the polygon ecosystem which leverages the element of randomness.
Secondly, our project also helps in achieving cross-chain data transfer by leveraging the hyperlane protocol. Thus, reducing the interchain communication barrier.
And lastly, we have demonstrated the above two use cases of our project by building a cross-chain trump card NFT game. In this game, players from the different chains can play with each other while maintaining a consistent game state across the chains.
In the game, each participant can mint trump card NFTs, which have certain associated attributes such as Stamina, attack and defence. Each player can send a challenge invite to another player, and once accepted, both the player's trump cards battle against each other and a single card emerges victorious based on the attribute strengths. The cards used in the battle for each player are selected randomly from the pool of NFTs owned by the player. Both players can be on different chains. The challenge invitations by players are sent as notifications to opponents using push notification protocol.
Firstly, we faced a lot of difficulties while using the moonbeam's randomness precompiles.
In moonbeam, to obtain the randomness value, it is a two-step process and this requires us to make two transaction calls to the hyperlane protocol for cross-chain data transfer which is quite a hassle. Also, in the hyperlane protocol, we can't read the return value of transaction. So to transfer the VRF(verifiable random function) value from one chain to another through hyperlane, we had to introduce another callback. And these steps were not mentioned properly in the hyeperlane docs. Also, we had to change our implementation midway as we were not able to call payable functions through hyperlane.