Win MANA and LAND in Decentraland's Creator Contest! Sign up today
Hello! Please choose your
desired language:

User data

Track user position and rotation

The Camera object exposes information about the user’s point of view in your scene.

  • camera.position returns a 3D vector with the user’s coordinates relative to the scene.
  • camera.rotation returns a quaternion with the user’s rotation.

Tip: You can also obtain the user’s rotation expressed in Euler angles (as an x, y and z vector) by writing camera.rotation.eulerAngles.

const camera = Camera.instance

class CameraTrackSystem {
  update() {

The example above logs the user’s position and rotation on each frame.

const camera = Camera.instance

class SomeSystem implements ISystem {
  constructor() {

  update() {
    for (let i in this.entities) {
      const entity = this.entities[i]
      const transform = entity.get(Transform)

const cube = new Entity()
const shape = new BoxShape()
const transform = new Transform()
transform.position.set(5, 1, 5)

engine.addSystem(new SomeSystem())

The example above uses the user’s rotation to set that of a cube in the scene.

Get user’s public Ethereum key

You can obtain a user’s public Ethereum key by using getUserPublicKey(). You can then use this information to send payments to the user, or as a way to recognize users.

The example below imports the Identity library and runs getUserPublicKey() to get the public key of the user’s Ethereum account and log it to console. The user must be logged into their Metamask account on their browser for this to work.

import { getUserPublicKey } from "@decentraland/Identity"

const publicKeyRequest = executeTask(async () => {
  const publicKey = await getUserPublicKey()
  return publicKey

class IDSystem implements ISystem {
  update() {
    if (publicKeyRequest.didFail) {
      log("error fetching id" + publicKeyRequest.error)
    } else {
      log("id:" + publicKeyRequest.result)

Note that we’re using an async function to run the getUserPublicKey() function, as it might take some time to retrieve this data. We’re then handling the data in a system, to be able to use it whenever it’s ready.