Home

Treasury Accounts

Learn how to use your dev account to transfer accounts.

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.

Requisites#

To escrow assets to your dev account you need to either:

  • Support ERC-2771 transactions: The assets you want to escrow need to support ERC-2771 transactions (i.e. meta transactions). You can check the list of supported forwarder contracts.
  • Fund dev account: You need to fund your dev account with the native tokens of the network you're interacting with.

Quickstart#

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.

1. Create a dev account#

First, create your dev account in your dashboard or via API.

addDevAccount

2. 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.

server.ts

_22
// Set your secret key. Remember to switch to your live secret key in production.
_22
// See your keys here: https://dashboard.openfort.xyz/apikeys
_22
const Openfort = require('@openfort/openfort-node').default;
_22
const openfort = new Openfort(YOUR_SECRET_KEY);
_22
_22
const devAccount = 'dac_...';
_22
const playerId = 'pla_...';
_22
const policyId = 'pol_...';
_22
const amount = '1000000000000000000'; // 1 token
_22
_22
const transactionintents = await openfort.transactionIntents.create({
_22
account: devAccount,
_22
chainId: 80002,
_22
policy: policyId,
_22
optimistic: true,
_22
interactions:{
_22
contract: 'con_....',
_22
// The function name and arguments are specific to the contract you're interacting with
_22
functionName: 'transfer',
_22
functionArgs: [playerId, amount]
_22
}
_22
})