# 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'
}    
```
