Using Managed Wallets
The following page explains how to create Managed wallets using the Enjin Platform API.
Please refer to the API Docs for the full list of queries and mutations, or use the GraphiQL Docs Explorer (available once you have set an Authorization header, or are logged in to the Platform UI).
To create a Managed wallet, run the
CreateWallet
mutation, with a unique ID as a parameter.
For example, if you are developing a game, and you want to create a Managed wallet for each player, a good approach would be to assign the player's unique ID to the externalId
parameter, like so:mutation CreateManagedWallet {
CreateWallet(externalId: "player_1_id_here")
}
Once the Managed wallet is created, you can provide the
externalId
field of the Wallet
object to any query or mutation that accepts a Wallet.externalId
parameter, in order to use a Managed wallet instead of any other wallet.Lets look at the
GetWallet
query as an example, to get the Public Key of an account, you would normally use the account's address like so:query GetPublicKey {
GetWallet(account: "address_here") {
account {
publicKey
}
}
}
To get the Public Key of a Managed wallet, we provide the
Wallet.externalId
parameter instead:query GetManagedWalletPublicKey {
GetWallet(externalId: "player_1_id_here") {
account {
address
publicKey
}
}
}
With the acquired Managed wallet address, you can mint tokens directly to the Managed wallet:
mutation CreateToken {
CreateToken(
recipient: "managed_wallet_address_here"
collectionId: "2403"
params: {
tokenId:{integer:1}
initialSupply:1
unitPrice:10000000000000000
cap: {
type:INFINITE
}
}
) {
id
transactionId
transactionHash
method
state
encodedData
wallet {
account {
publicKey
address
}
}
}
}
If you followed along the previous snippets of code, you should have a Managed wallet with a token in it. To transfer it out to another wallet, we can use the
SimpleTransferToken
mutation:mutation TransferTokenFromManagedWallet {
SimpleTransferToken(
collectionId: 2403
recipient: "recipient_address_here"
params: {
tokenId: {integer: 1}
amount: 1
}
signingAccount: "managed_wallet_address_here"
){
id
method
state
}
}
Make sure that
signingAccount
is set to the Managed wallet address that owns that token.Last modified 24d ago