Guest players are a pattern common in mobile games that allow your players to open up the game, play, and even spend without having to first create an account.\
Guest players receive an on-chain wallet, and can own items on-chain, but have limited functionality compared to registered players, as shown in the following diagram. At a later point in the player’s journey, the guest player can be linked to their registered player, gaining full privileges.\
Guest player
Registered player
Play games
✅
✅
In-game marketplace
✅
✅
Web marketplace
❌
✅
Account management
❌
✅
Withdraw MYTH
❌
✅
When the game is initialized, create a guest player. The playerId should be persisted with the device.
// Create player when game is initializedconstresponse=awaitfetch('/v1/players',{ method:'POST', headers:{"x-mythical-environment-id":"123e4567-e89b-12d3-a456-426614174000"},});// Persist the player's id for use in future requestsconst{id}=awaitresponse.json();console.log( id // 9779f02d-5193-4ab1-ae15-f18e091f38e1)
Now, the playerId can be used to make other calls to the platform API, such as granting items.