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
Parameter
Description
message: string
The message to sign
isJsonObject?: boolean
Whether message is a json object
Success Response
Parameter
Description
publicKey: string
Public key of account that signed message
data: string
Original message signed
salt: string
Salt added to original message as prefix, before signing
message: string
Signed message
Error Response
Parameter
Description
type: string
The type of error which has occured
description: string
A description of the error which has occured
data: string
Any raw data associated with the error
Example
Request
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
{
publicKey: '"03ba9524bd7479414be713c3a4f6f3ef35f90bb4b08f0f552211bf734c24415230"',
data: '"be506bf7e6851960bfe45968bf5dbbf79a9dc5dc63ee5b88629acfb288c435649c2766e977d4bc76253d8590bb3ca3d9b70efd71d6f7eebdf060dfa58c6601fd"',
salt: '',
message: 'Hello world'
}
最后更新于
这有帮助吗?