# Link.sign

## Link.sign

LINK REFERENCE TOOL

Check out our <mark style="color:blue;">**Link reference tool**</mark> to understand how `Link` methods work without having to write any code.

SDK v1.14.1+ used with Link UI add support to request arbitrary L1 signatures. This feature provide some flexibility for the developer to request L1 signatures for different actions that are not core to the platform such as like, follow, comment, etc.

### Parameters[​](https://docs.x.immutable.com/docs/x/linksign#parameters) <a href="#parameters" id="parameters"></a>

This method requires message that an engineer wants to sign and description that presents a user friendly message that will be shown to a user

```
{
  "message": "NonEmptyString",
  "description": "NonEmptyString"
}
```

### Usage[​](https://docs.x.immutable.com/docs/x/linksign#usage) <a href="#usage" id="usage"></a>

To sign a message an engineer needs to call the method sign()

```
link.sign({
  message: 'My awesome message',
  description: 'Message that a user will see',
});
```

![Sign Message](https://3017072639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7a6afyDwSEkvWtt1UhmH%2Fuploads%2F0OMd0m4BlOyJngNLK3aN%2F1.da%20%E7%AC%AC%E4%BA%8C%E8%A1%8C%20x.immutable%E3%80%82%E6%94%B9.png?alt=media\&token=28c82e56-37d2-4608-b0fc-c1ec77813c76)

If a user successfully signed a message, link.sign() will be resolved with the value:

```
{
  "result": "0x0d8705969ea15dac4f684f5f5a7a3447f514b07c96c7a9bb21588ef33821caed63f204c11f0ed69777132c8fa25af62c883627169c7b5b46f23b132db46e7d8d1c"
}
```

### Errors[​](https://docs.x.immutable.com/docs/x/linksign#errors) <a href="#errors" id="errors"></a>

If a user denied to sign a message, link.sign() will return rejected promise.

Also, there is an error screen that will be appeared if a message cannot be sign as contains forbidden message

![Sign Message Error](https://3017072639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7a6afyDwSEkvWtt1UhmH%2Fuploads%2FnWxyLQnR7lv1gOteatDj%2F2.png?alt=media\&token=9fe6e6b5-64da-4398-b0c2-9ea9be48ce2b)

### Encryption public key[​](https://docs.x.immutable.com/docs/x/linksign#encryption-public-key) <a href="#encryption-public-key" id="encryption-public-key"></a>

To get an encryption public key an engineer needs to call the method getPublicKey(). This method is available from SDK v1.16.0+

```
link.getPublicKey({});
```

An example for Metamask provider:

![Request Encryption Public Key](https://3017072639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7a6afyDwSEkvWtt1UhmH%2Fuploads%2FtGSfsj7QTFPLBkHRy3zg%2F3%E5%9B%BE%E6%A0%87.png?alt=media\&token=25c6a69c-cd4a-4d72-a2b8-e70036f8b5a4)

If a user allowed to provide a public encryption key, link.getPublicKey() will be resolved with the value:

```
{
  "result": "1Afjjdub580LjsizQtlDmrSZ+BZIiydkx4BGRb2DDBI="
}
```
