# ChangePubKey

[ChangePubkey](/developer/api-and-sdk/transaction/change_pubkey.md) transaction type.

```dart
ChangePubkey(
    int chainId,
    int accountId,
    int subAccountId,
    String newPubkeyHash,
    int feeToken,
    String fee,
    int nonce,
    String? ethSignature,
    int? ts,
)
```

## func getEthSignMsg

```dart
String getEthSignMsg(int nonce, int accountId)
```

Get the Ethereum sign message

## func sign

```dart
void sign(ZkLinkSigner zkLinkSigner)
```

Sign transaction with given [ZkLinkSigner](/developer/sdk/changelog-2/signer.md#type-zklinksigner)

## func toJson

```dart
String toJson()
```

Get the json str of [ChangePubKey](#type-changepubkey)

## func toEip712RequestPayload

```dart
String toEip712RequestPayload(int chainId, String address)
```

Get the EIP-712 structured data of [ChangePubKey](#type-changepubkey)

## func setEthAuthData

```dart
void setEthAuthData(String sig)
```

Set Ethereum authentication data with given EthECDSA signature

## Example

```dart
var zklinkSigner = ZkLinkSigner.ethSig(sig: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
String pubkeyHash = zklinkSigner.getPubkeyHash();
print(pubkeyHash);
var tx = ChangePubKey(
    chainId: 1,
    accountId: 2,
    subAccountId: 4,
    newPubkeyHash: pubkeyHash,
    feeToken: 1,
    fee: "100",
    nonce: 100
);
tx.sign(zkLinkSigner: zklinkSigner);
print(tx.toEip712RequestPayload(chainId: 1, address: "0xa97153dd89c6f8F3BeA66190a6e62020aC7213de"));
String ethSignMsg = tx.getEthSignMsg(nonce: 100, accountId: 1);
tx.setEthAuthData(sig: "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b");
print(tx.toJson());
```


---

# Agent Instructions: 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:

```
GET https://docs.zk.link/developer/sdk/changelog-2/transactions/1-change-pubkey.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
