The xRegister Function

How we are allowing players to register to the game without having to pay gas

Goals:

  • Being able to register on any chain

  • Being able to register without paying gas

  • Being able to register without a wallet

  • Being able to register with the ecosystem wallets

    /**
     * @notice Necessary to create the mirror wallet link
     * @dev Deployer Required
     * @param _playerWallet: real EOW of user
     * @param _internalWallet: walled used to relay txns
    */
    function createPlayer(address _playerWallet, address _internalWallet) public payable onlyOwner {
        require(players[_playerWallet].internalAddress == 0x0000000000000000000000000000000000000000, "Player already exists");
        players[_playerWallet].internalAddress = _internalWallet;
        players[_playerWallet].glmbAvailable = 0;
        players[_playerWallet].shakesAvailable = freeShakes;
        players[_playerWallet].gamesPlayed = 0;
        playersReversed[_internalWallet] = _playerWallet;
    }

As you can see, this function is callable only by the deployer. This allows us to relay the transaction as explained in the Build a custodial solution to make your dApp wallet-less & gas-less using EIP-712

The front-end is collecting the necessary information, especially the playerWallet that'll be used as the first argument.

The internal wallet (aka mirror wallet) is simply created by the backend using a simple ethers function:

 const mirrorWallet = await ethers.Wallet.createRandom()
 newPlayer.insideWallet = await mirrorWallet.address
 newPlayer.insideKey = await mirrorWallet.privateKey

Last updated