Backend wallets
Backend wallets, are externally-owned accounts to be used internally to manage the game flows and experience.
They can execute game logic like escrow for competition or sending a minted asset to a player after winning a competition.
Please refer to our guide on how to create backend wallets to learn how to create them through your Openfort dashboard.
Minting#
Designed for situations where controlled minting is necessary, typically governed by a contract allowing only certain addresses to mint new assets.
You might have contracts deployed that need to be minted on-demand, (we recommend having a pre-defined allowlist of addresses that are able to mint assets for the contract).
These accounts are included in a contract's allowlist, which specifies who can mint assets. To set up a minting account, a dev account is created, and its address is added to this allowlist. This process ensures that only authorized backend wallets can initiate the minting process.
Minting an asset#
To minting an asset create a new transactionIntent using the dev account.
To sponsor the transaction, the contract NFT supports ERC-2771 transactions. If not, you need to fund the dev account with the native tokens of the network you're interacting with.
Therefore, we set a policy with a policy rule account_functions
that allows the dev account interactions. Learn how to create a policy sponsor.
If you would like to mint an asset to a player's account, do the following:
Treasury#
Using your dev account to manage pre-minted on-chain assets. Ideal for games requiring a fixed set of pre-minted assets.
A Treasury account operates as a standard EOA, authorized via an API key. After integrating your game's pre-minted assets into our contracts, you transfer these assets to the treasury account's address. This setup enables you to redistribute the assets from the Treasury to other accounts within your game.
If pre-minted assets get distributed in batches, you might want to create a treasury account per batch - or periodically send assets to the treasury's address - managing these accounts is up to you.
Transferring an asset#
Once you have a dev account, you can transfer assets to it.
To sponsor the transaction, the contract supports ERC-2771 transactions. If not, you need to fund the dev account with the native tokens of the network you're interacting with.
Therefore, we set a policy with a policy rule account_functions
that allows the dev account interactions. Learn how to create a policy sponsor.
You're all set, you can now transfer assets to the player's account.
Escrow#
Using your dev account to escrow assets where players put their assets on the line. For example, when players participate in PvP-match.
These accounts ensure fair play by holding players' assets during a game, preventing dishonest tactics like disconnecting or transferring assets when facing a likely loss.
1. Creation: When a player, say Player A, initiates a PvP match, the game developer creates a escrow account. This backend wallets, distinct from any user account, holds assets wagered by the players. 2. Asset Transfer: Players, A and B, choose an asset each for the match. Through the game's interface, they transfer these assets to the escrow account. Once transferred, the assets are out of the players' control. 3. Validation: The game system verifies the transfer by checking the assets in the escrow account. A simple count of the assets confirms whether the match is set to begin.
Asset transfers to Escrow account#
Now, let's assume two players are matched and both need to decide what asset (let's say an NFT) they want to deposit in the escrow account to start the game.
To do that, they both need to select the tokenId from the NFT
they want to escrow.
Once both players have chosen their assets, move them to the escrow account. You will need to do this for each of the players with the asset they want to escrow:
Bear in mind, here we're using a policy
sponsor to pay for the gas fees. Learn how to create a policy sponsor.
The assets are now in the escrow account and the game can start.
After the game finishes, you can transfer the assets back to the players' accounts using the same process changing the receiver
and playerId
parameters.
To sponsor the transaction, the contract supports ERC-2771 transactions. If not, you need to fund the dev account with the native tokens of the network you're interacting with.
Therefore, we set a policy with a policy rule account_functions
that allows the dev account interactions.