> 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/blob/main/contributor/content/entity-types/scenes/README.md) 访问 [个人资料](https://github.com/decentraland/docs/blob/main/contributor/content/entity-types/profiles/README.md) 玩家用户的。

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

它包含以下方法和类型：

* [`function getUserData`](#getUserData)
* [`interface 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/blob/main/contributor/content/overview/README.md).

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

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

  // 在界面中称呼他们的名称。
  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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
