Sign Raw Transaction
This 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 broadcasted to the network using the send_raw_transaction to complete the process.
Request Parameters
| Structure | Type | Description |
|---|---|---|
| coin | string | The coin to sign the raw transaction with |
| type | string | The operation type. Accepted values: UTXO ( for utxo coins), ETH (for emv coins) |
| tx | object | A standard RawTxInfo object |
Response Parameters
| Structure | Type | Description |
|---|---|---|
| tx_hex | string | The signed transaction hex, ready for broadcast |
Sign UTXO raw transaction hex
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
} curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"sign_raw_transaction","params":{"coin":"KMD","type":"UTXO","tx":{"tx_hex":"0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"}},"id":0}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
Response (success)
{
"mmrpc": "2.0",
"result": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd036020000006a47304402206b40df6d7b1d87622ea1eba0cdce09dfaf21556a408b2bd245920c2f3e9ff5e702201bd7bcc9587a9731cfd7c57057f173cbf635d2818263a96f211c413f6e83d187012103d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
},
"id":0
} Sign UTXO raw transaction hex 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
}
]
}
}
} curl --url "http://127.0.0.1:7783" --data '{
"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
}
]
}
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"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
}
]
}
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"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
}
]
}
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"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
}
]
}
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"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}]}}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"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
}
]
}
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Response (success)
Show Response
{
"mmrpc": "2.0",
"result": {
"tx_hex": "020000000001010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e2024730440220156d185b3fb21725c040b7ddcf84bf862b46f079bb66067eef1941023b8451e602204d877ac51b74932dea34c20874fa8112b3636eb506ac429548f7c05fe54e3faf0121039ad38f67dbc22cf5a6bd48b26920d9fac71681836faf80a9a678ddbaa0fe92f800000000"
},
"id":0
} Signed an 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"
}
}
}
} curl --url "http://127.0.0.1:7783" --data '{
"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"
}
}
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"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"
}
}
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"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"
}
}
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"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"
}
}
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"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"}}}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"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"
}
}
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Response (success)
{
"mmrpc": "2.0",
"result": {
"tx_hex": "f86680847735940083021000947bc1bbdd6a0a722fc9bffc49c921b685ecb84b948210008025a06c0ecbccf92caf5ac620b118f09a84a18c73d7b209e75696bb10e3c24c2dba64a055af3638f92daec1eb3057fb6a9ccf418325bb1aa6121a3314c3885100a5e63a"
},
"id": 0
}
Errors
Show Errors
Signing Error
You might see this if you try to sign a raw transaction that belongs to a different key pair.
{
"mmrpc":"2.0",
"error":"Signing error: with_key_pair:114] P2PKH script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0xd346067e3c3c3964c395fee208594790e29ede5d\nOP_EQUALVERIFY\nOP_CHECKSIG\n' built from input key pair doesn't match expected prev script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0x32311a35188a9439c6c866e842564d6fefd3a028\nOP_EQUALVERIFY\nOP_CHECKSIG\n'","error_path":"utxo_common","error_trace":"utxo_common:3144]",
"error_type":"SigningError",
"error_data":"with_key_pair:114] P2PKH script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0xd346067e3c3c3964c395fee208594790e29ede5d\nOP_EQUALVERIFY\nOP_CHECKSIG\n' built from input key pair doesn't match expected prev script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0x32311a35188a9439c6c866e842564d6fefd3a028\nOP_EQUALVERIFY\nOP_CHECKSIG\n'",
"id":0
}Invalid Request
{
"mmrpc":"2.0",
"error":"Error parsing request: invalid digit found in string",
"error_path":"dispatcher",
"error_trace":"dispatcher:108]",
"error_type":"InvalidRequest",
"error_data":"invalid digit found in string",
"id":0
}Invalid Parameter
{
"mmrpc":"2.0",
"error":"Invalid param: Invalid input length",
"error_path":"eth",
"error_trace":"eth:2544]",
"error_type":"InvalidParam",
"error_data":"Invalid input length",
"id":0
}No Such Coin
Coin does not exist or has not been activated.
{
"mmrpc":"2.0",
"error":"No such coin NOTSURE",
"error_path":"lp_coins",
"error_trace":"lp_coins:3965] lp_coins:3861]",
"error_type":"NoSuchCoin",
"error_data":{
"coin":"NOTSURE"
},
"id":0
}