Sign Raw Transaction
API-v2sign_raw_transaction
The sign_raw_transaction
method allows users to:
- Create a signed UTXO raw transaction given unsigned hex, and optionally a set of prior transaction inputs.
- Create a signed EVM raw transaction, given the destination address, amount, and gas limit.
The transaction can then be broadcast to the network using the send_raw_transaction
method to complete the process.
This method is used to sign a raw transaction that has already been created.
For UTXO coins, the unsigned hex is required to sign the transaction.
If prev_txns
is not provided, it will be sourced via Electrum servers.
Parameter | Type | Required | Description |
---|---|---|---|
coin | string | ✓ | The coin to sign the raw transaction with. |
type | string | ✓ | The operation type. Accepted values: UTXO (for UTXO coins), ETH (for EVM coins). |
tx | object | ✓ | A standard RawTxInfo object. |
Parameter | Type | Description |
---|---|---|
tx_hex | string | The signed transaction hex, ready for broadcast. |
Sign UTXO Raw Transaction
POST
sign_raw_transaction{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}
Sign UTXO Raw Transaction with Inputs
POST
sign_raw_transaction{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"id": 0,
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000",
"prev_txns": [
{
"tx_hash": "36d01c2a80a05236f69b5a6d6819978c7d3b7bf3992b59c0adbb514e76d8d6c8",
"index": 2,
"script_pub_key": "76a914d346067e3c3c3964c395fee208594790e29ede5d88ac",
"amount": 0.00001
}
]
}
}
}
Sign ETH/EVM Raw Transaction
POST
sign_raw_transaction{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"id": 0,
"method": "sign_raw_transaction",
"params": {
"coin": "MATIC",
"type": "ETH",
"tx": {
"to": "0x927DaFDDa16F1742BeFcBEAE6798090354B294A9",
"value": "0.85",
"gas_limit": "21000",
"pay_for_gas": {
"tx_type": "Eip1559",
"max_fee_per_gas": "1234.567",
"max_priority_fee_per_gas": "1.2"
}
}
}
}
Once you have signed the raw transaction, do not forget to broadcast it to the network using the send_raw_transaction
method.
Parameter | Type | Description |
---|---|---|
SigningError | string | Error when signing a raw transaction that belongs to a different key pair |
InvalidRequest | string | Error parsing request: invalid digit found in string |
InvalidParam | string | Invalid parameter: Invalid input length |
NoSuchCoin | string | Coin does not exist or has not been activated |