Skip to content

sign_raw_transaction rpc examples

dimxy edited this page Nov 29, 2023 · 7 revisions

Example for UTXO Coin

Enable UTXO coin:

curl --url "http://127.0.0.1:7783" --data '{
	"userpass": "some_password",
	"coin": "tBTC",
	"method": "electrum",
	"servers": [
		{"url": "electrum1.cipig.net:10001"},
		{"url": "electrum2.cipig.net:10001"},
		{"url": "electrum3.cipig.net:10001"}
	],
	"required_confirmations":10,
	"requires_notarization":true,
	"mm2":1
}'

Call sign_raw_transaction for UTXO coin:

curl --url "http://127.0.0.1:7783" --data '{ 
  "userpass": "some_password",
  "mmrpc":"2.0",
  "id": 0,
  "method": "sign_raw_transaction",
  "params": {
     "coin": "tBTC",
     "type": "UTXO",
     "tx": {
         "tx_hex": "02000000010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e200000000",
         "prev_txns": [{
                "tx_hash": "0d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb2",
                "index": 1,
                "script_pub_key": "001449e3b6b4684c4d4a914b29411af51843c59bfff0",
                "amount": 0.00001000
         }]
      }
   }
}'

Expected response:

{"mmrpc":"2.0","result":{"tx_hex":"020000000001010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e2024730440220156d185b3fb21725c040b7ddcf84bf862b46f079bb66067eef1941023b8451e602204d877ac51b74932dea34c20874fa8112b3636eb506ac429548f7c05fe54e3faf0121039ad38f67dbc22cf5a6bd48b26920d9fac71681836faf80a9a678ddbaa0fe92f800000000"},"id":0}

Example for ETH Coin

Enable ETH coin:

curl --url "http://127.0.0.1:7783" --data '{
        "userpass": "some_password",
	"coin": "ETH",
	"method": "electrum",
	"urls": [ "http://195.201.137.5:8545" ],
	"mm2":1,
	"swap_contract_address": "0x83965c539899cc0f918552e5a26915de40ee8852"
	
}'

Call sign_raw_transaction for ETH coin:

curl --url "http://127.0.0.1:7783" --data '{ 
  "userpass": "some_password",
  "mmrpc":"2.0",
  "id": 0,
  "method": "sign_raw_transaction",
  "params": {
     "coin": "ETH",
     "type": "ETH",
     "tx": {
        "to": "0x7Bc1bBDD6A0a722fC9bffC49c921B685ECB84b94",
        "value": "1.2345",
        "gas_limit": "21000",
        "data": "DEAD1234567890"
     }
  }
}'

Expected response:

{"mmrpc":"2.0","result":{"tx_hex":"f87380847735940083021000947bc1bbdd6a0a722fc9bffc49c921b685ecb84b94880de444324c2a800087dead123456789025a02f414dbbf6958c13bfa457968587d1b7ad0b36cacd1645a8584bd8432ae92788a07dbbc9b4c2d1acc34eaaf8f0f7ed4b5b15bd9f6ecf140460aeeba4b71bbf5e16"},"id":0}
Clone this wiki locally