Metaplay©: Revolutionising Betting on ZKasino with One-Click Gasless Transactions

4 min readJul 10, 2023



Metaplay© is a groundbreaking technology developed by ZigZag Labs, specifically by Trooper, that is set to redefine the user experience in the world of decentralised applications (dApps), particularly in Web3-gaming. This innovative technology, which can be integrated into any dApp, introduces a new way of betting on ZKasino, enabling one-click gasless transactions.

With a single click on the Play button, users can start playing without any wallet pop-ups, a significant shift from the traditional Web3 user experience. The fees for these transactions are paid in ERC-20 bet tokens, eliminating the need for native tokens whilst playing. Users only need to authorise their wallets once a month after the initial setup.

Technical Overview

Technically, Metaplay can be described as a combination of native meta transactions and session keys.

Session Wallet: Frontend and Trusted Forwarder

The first requirement for Metaplay© is a session wallet. This wallet is allowed to sign requests on behalf of the wallet that generated the session wallet (transaction signer). The frontend checks if a session private key is stored on localStorage. If there is, the frontend uses that key. If there’s not, the frontend calls an ether.js function to generate a new, random session wallet with a session private key.

The key is then stored in the user’s browser in localStorage, allowing the user to continue using Metaplay© across sessions and tabs. The user can remove the key from the browser at any time. The session wallet is then set up on-chain on the Trusted Forwarder contract by calling the setSigner function, which involves confirming a transaction. The session wallet address is enabled and saved in the Forwarder contract, the game contracts (‘targets’) are batch approved, and an expiry time for the session wallet is set (one month). After one month, the user needs to re-approve. During the month, the user can revoke the allowance for the session wallet at any time.

Gasless Meta Transactions

The session wallet can be used for gasless meta transactions based on ERC-2771. Fees are paid in ERC-20 bet tokens, such as USDC. Tokens with a reliable price feed are eligible to become Metaplay© bet tokens. The user needs to approve the bet tokens on the Forwarder contract, which involves confirming a transaction.

Metaplay© is unavailable for native tokens (ETH, FTM, MATIC).

Whenever a user clicks ‘Play’, the frontend code accesses the session private key from the user. The frontend code uses the key of the session wallet which is authorised to sign EIP-712 signature requests on behalf of the user’s wallet. In short, the frontend handles the signing for the user, removing the need for any pop-ups from the wallet. The off-chain request is then sent to the backend server.

Backend (Gas Relayer)

The backend server receives the user’s request. The backend verifies that the transaction does not fail if it gets executed and sends the transaction on-chain. Then the signature and nonce are checked to make sure the user signed the request to keep the user safe.

Game Contracts (Recipient)

The casino contracts underwent minimal changes. The most important change is finding out who is sending the transaction, because the Forwarder contract executes transactions on behalf of the user. This is done with the function function _msgSender(), which can be found on the Common.sol and game contracts.

Forwarder Extra

The forwarder contract keeps track of the user’s set and signed (immutable) gasLimit and Value sent to convert those values to the ERC-20 fee token chosen by the user and collected from the user. This is also the reason an approval is needed for the fee token. The operator pays transaction and VRF fees, so fees need to be collected from the user to cover the cost from the operator.

Future Improvements

ZigZag Labs plans to further improve Metaplay© by:

Lowering gas costs by batching requests when there is a high number of requests.

Modifying the calldata on Arbitrum to use less space on L1, making it cheaper.

Decentralising the operator (gas relayers).

Subsidising bet fees.

Allowing approval without native token.

Removing approvals for fee token through subsidising those fees.

Batch pay upfront for transactions.

Metaplay© is a game-changer for the world of dApps, especially Web3-gaming, offering a seamless, one-click, gasless betting experience on ZKasino. Its innovative approach to transactions and user experience sets a new standard for the industry.

Join the discussion at:




Decentralised betting platform built for Layer-2 ZK Rollups.