Sign Message

Allows for the signing of arbitrary payloads using the authenticated user’s signer. The payload to be signed should be included within the body of a stamped request, ensuring the integrity and authenticity of the message to be signed. This operation is important for executing transactions and interactions on the blockchain that require verified signatures from the user’s wallet.

Headers

AuthorizationstringRequired

Request

This endpoint expects an object.
stampedRequestobjectOptional

A stamped request that includes the payload to be signed. The payload is part of the stamped request’s body, which should conform to the structure outlined in the Turnkey API documentation for signing raw payloads.

Because users are given wallets for both Ethereum and Solana, it’s possible to request signatures for both chains. The following is an example of the payload structure for signing bytes on Ethereum and Solana:

Signing bytes for Ethereum:

{
organizationId: this.user.orgId,
type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
timestampMs: Date.now().toString(),
parameters: {
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
hashFunction: "HASH_FUNCTION_NO_OP",
payload: msg,
signWith: this.user.address,
},
}

Signing bytes for Solana:

{
organizationId: this.user.orgId,
type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
timestampMs: Date.now().toString(),
parameters: {
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
hashFunction: "HASH_FUNCTION_NOT_APPLICABLE",
payload: msg,
signWith: this.user.solanaAddress,
},
}

For more details on the parameters of the request body, see Turnkey’s API Reference.

Response

Message signing successful.

signaturestringOptional

The signature generated for the specified payload.