signRawTransaction
Introduction
The signRawTransaction method is a key component of the offline transaction and cold storage workflow. Its sole purpose is to take a serialized, unsigned transaction (typically generated by createRawTransaction) and apply a valid cryptographic signature.
This endpoint requires that the node's loaded wallet contains the private key corresponding to the public key specified in the raw transaction's pubKey field. It then returns the fully signed, serialized transaction, ready for broadcast via sendRawTransaction.
Request
Requests can be made using either HTTP POST with a JSON body or HTTP GET with URL query parameters. Due to the potentially very long transaction string, POST is strongly recommended.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
transaction | string | Yes | The hex-encoded string of the raw, unsigned transaction to sign. |
Example POST Request
POST /signRawTransaction
Content-Type: application/json
{
"jsonrpc": "2.0",
"method": "signRawTransaction",
"params": {
"transaction": "0700fd200d010001010005402a...0100010000"
},
"id": 1
}
Example GET Request
The transaction parameter is provided as a URL query string.
GET /signRawTransaction?transaction=0700fd200d010001010005402a...0100010000
Response
The response result is a single hex-encoded string representing the complete, serialized transaction with the newly added signature.
Example Success Response
{
"jsonrpc": "2.0",
"result": "0700fd200d010001010005402a...563c7b1d44c900",
"error": null,
"id": 1
}
Example Error Response
This error is returned if the mandatory transaction parameter is not included in the request.
{
"jsonrpc": "2.0",
"result": null,
"id": 1,
"error": {
"code": -32602,
"message": "transaction parameter is missing"
}
}
Behavioral Notes
- Wallet Requirement: The node executing this call must have a loaded wallet that contains the private key corresponding to the public key embedded within the provided raw transaction data. If the key is not available, the signing operation will fail.
- Idempotency: This operation is idempotent. Signing the same unsigned transaction multiple times with the same key will produce the same signed transaction.
- Workflow Integration: This method is the second step in a typical three-step offline signing process:
createRawTransaction: Generate an unsigned transaction on an online (but untrusted) machine.signRawTransaction: Transfer the hex string to an offline, secure machine with the wallet key to sign it.sendRawTransaction: Transfer the resulting signed hex string back to an online machine to broadcast it to the network.