> For the complete documentation index, see [llms.txt](https://tutorial.neoline.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tutorial.neoline.io/reference/neo2-provider-api/write-methods/signmessage.md).

# signMessage

Signs a provided messaged with an account selected by user. A randomized salt prefix is added to the input string before it is signed, and it is encased in a non-executable transaction before signed. This ensures compatibility with Ledger devices.

## **Input Arguments**

<table><thead><tr><th width="313">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>message: string</code></td><td>The message to sign</td></tr><tr><td><code>isJsonObject?: boolean</code></td><td>Whether message is a json object</td></tr></tbody></table>

## **Success Response**

<table><thead><tr><th width="307">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>publicKey: string</code></td><td>Public key of account that signed message</td></tr><tr><td><code>data: string</code></td><td>Original message signed</td></tr><tr><td><code>salt: string</code></td><td>Salt added to original message as prefix, before signing</td></tr><tr><td><code>message: string</code></td><td>Signed message</td></tr></tbody></table>

## **Error Response**

<table><thead><tr><th width="304">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type: string</code></td><td>The type of error which has occured</td></tr><tr><td><code>description: string</code></td><td>A description of the error which has occured</td></tr><tr><td><code>data: string</code></td><td>Any raw data associated with the error</td></tr></tbody></table>

## Example

### Request

```js
neoline.signMessage({
  message: 'Hello world'
})
.then(signedMessage => {
  const {
    publicKey,
    message,
    salt,
    data
  } = signedMessage;

  console.log('Public key used to sign:', publicKey);
  console.log('Original message:', message);
  console.log('Salt added to message:', salt);
  console.log('Signed data:', data);
})
.catch((error) => {
  const {type, description, data} = error;
  switch(type) {
    case UNKNOWN_ERROR:
        console.log(description);
        break;
    default:
        // Not an expected error object.  Just write the error to the console.
        console.error(error);
        break;
  }
});
```

### Response

```js
{
  publicKey: '"03ba9524bd7479414be713c3a4f6f3ef35f90bb4b08f0f552211bf734c24415230"',
  data: '"be506bf7e6851960bfe45968bf5dbbf79a9dc5dc63ee5b88629acfb288c435649c2766e977d4bc76253d8590bb3ca3d9b70efd71d6f7eebdf060dfa58c6601fd"',
  salt: '',
  message: 'Hello world'
}    
```


---

# 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://tutorial.neoline.io/reference/neo2-provider-api/write-methods/signmessage.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.
