> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-zh/chang-jing-yun-xing-shi/yun-xing-shi-mo-kuai/user-identity.md).

# 用户身份

该 `UserIdentity` 模块允许 [场景](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/scenes/README.md) 访问 [资料](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/profiles/README.md) 玩家用户的。

```ts
const UserIdentity = require("~system/UserIdentity");
```

它包含以下方法和类型：

* [`函数 getUserData`](#getUserData)
* [`接口 UserData`](#UserData)

### 方法

此模块中的两个方法从玩家用户获取部分信息。

**`getUserData`**

返回 [`UserData`](#UserData) 玩家用户的。

```ts
interface Request {}

interface Response {
  // 用户的资料信息（如果可用）。
  data?: UserData;
}

function getUserData(Request): Promise<Response>;
```

### 类型

此模块中只有一种类型： `UserData`.

**`UserData`**

包含用户、其身份和头像的信息（可能不完整）。

World Explorers 可以通过 [内容系统](https://github.com/decentraland/docs/tree/main/contributor/content/overview/README.md).

该 [资料实体定义](https://github.com/decentraland/docs/tree/main/contributor/content/entity-types/profiles/README.md) 详细说明了所有这些字段以及更多内容。虽然……的结构和键 `UserData` 略有不同，但每个字段的含义相同。

```ts
export interface UserData {
  // 用户的以太坊地址。
  userId: string;

  // 在 UI 中称呼他们的名称。
  displayName: string;

  // 他们用于签名的以太坊公钥。
  publicKey?: string;

  // 他们是否启用了 web3 功能。
  hasConnectedWeb3: boolean;

  // 此信息的顺序版本，每次用户更新时递增。
  version: number;

  // 他们头像的信息（如果可用）。
  avatar?: {
    // 渲染此头像所需资源的指针。
    bodyShape: string;
    wearables: string[];

    // 不同身体部位的十六进制编码 RGB/RGBA 颜色（#aabbcc 或 #aabbccdd）。
    skinColor: string;
    hairColor: string;
    eyeColor: string;

    // 此头像“照片”的文件标识符。
    snapshots?: {
      face256: string;
      body: string;
    };
  };
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/contributor/contributor-zh/chang-jing-yun-xing-shi/yun-xing-shi-mo-kuai/user-identity.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
