> For the complete documentation index, see [llms.txt](https://docs.aftermath.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aftermath.finance/for-developers/typescript-sdk/utils/users-data.md).

# Users Data

## Users Data

### Initialization

```typescript
const afSdk = new Aftermath("MAINNET");
await afSdk.init(); // initialize provider

const userData = afSdk.UserData();
```

### Get Users Public Key

```typescript
const publicKey = userData.getUserPublicKey({
	walletAddress: "0x.."
});
```

### Create User Public Key

```typescript
const messageToSign = userData.createUserAccountMessageToSign();

const signedMessage = await signPersonalMessage({
	message: new TextEncoder().encode(JSON.stringify(messageToSign)),
});

const publicKey = userData.createUserPublicKey({
	walletAddress: "0x..",
	bytes: signedMessage.bytes,
  	signature: signedMessage.signature
});
```

### Complete Example

```typescript
import { Aftermath } from "aftermath-ts-sdk";
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
import dotenv from "dotenv";

dotenv.config();

const privateKeyHex = String(process.env.SECRET); // Use your own secret key
const keyPair = Ed25519Keypair.fromSecretKey(privateKeyHex);
const walletAddress = keyPair.getPublicKey().toSuiAddress();

const aftermath = new Aftermath("MAINNET");
const userData = aftermath.UserData();

const test = async () => {
	const messageToSign = userData.createUserAccountMessageToSign();
	const message = new TextEncoder().encode(JSON.stringify(messageToSign));

	const signedMessage = await keyPair.signPersonalMessage(message);

	const success = await userData.createUserPublicKey({
		...signedMessage,
		walletAddress,
	});

	const userPk = await userData.getUserPublicKey({
		walletAddress,
	});

	console.log({ success, userPk });
};

test();
```


---

# 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.aftermath.finance/for-developers/typescript-sdk/utils/users-data.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.
