# signMessageV2

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. **For the complete signing process, please go to** [**Testbed**](https://neoline.io/signMessageV2)**.**

## **Input Arguments**

<table><thead><tr><th width="331">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="321">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="322">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
neolineN3.signMessageV2({
  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: '023e72b8b5a20c00dac7ac01ecd72354a2d7d64620d6615524bb18b9f5a6ca8ef4',
  data: '4fef4abd1ced91577c89eac7909b89ec2aa3d073178c51c3074b7bc5551093b00bf274f35f8166931dc90cbd88346729e86e0bf1c3014fa3587cc167f0cafd4c',
  salt: '543e66d70a56506f0a69aff35f25f794',
  message: 'Hello world'
}
```
