Ask or search…
K
Links

createrawtransaction

How to use it

TypeScript/JavaScript
1
// yarn add @tatumio/tatum
2
3
import { TatumSDK, Litecoin, Network } from '@tatumio/tatum'
4
5
const tatum = await TatumSDK.init<Litecoin>({network: Network.LITECOIN})
6
7
const result = await tatum.rpc.createRawTransaction([
8
{
9
"txid": "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234",
10
"vout": 0
11
}
12
],
13
{
14
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa": 0.01
15
})
16
17
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The createrawtransaction RPC method creates an unsigned raw transaction that spends a set of previous transaction outputs to a set of new addresses with specific amounts. The method can be used to create custom transactions, which can then be signed and broadcast to the Litecoin network.

Parameters

  • inputs: (array, required) An array of objects, each specifying a previous transaction output to spend.
    • txid: (string, required) The transaction ID of the previous transaction output to spend.
    • vout: (numeric, required) The index of the output to spend from the previous transaction.
    • sequence: (numeric, optional) default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number
  • outputs: (object, required) An object with the key-value pairs representing the receiving address and the amount to be sent (in BTC).
  • locktime: (numeric, optional, default=0) The lock time for the transaction. It can be used to specify the earliest time or block height at which the transaction can be included in a block.
  • replaceable: (boolean, optional, default=false) Marks this transaction as BIP125-replaceable. Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.

Return Object

  • (string) A hex-encoded raw transaction.

JSON Examples

Request example:
1
{
2
"jsonrpc": "2.0",
3
"id": 1,
4
"method": "createrawtransaction",
5
"params": [
6
[
7
{
8
"txid": "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234",
9
"vout": 0
10
}
11
],
12
{
13
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa": 0.01
14
}
15
]
16
}
Response example:
1
{
2
"result": "02000000013412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab3412cdab0000000000fdffffff0140420f00000000001976a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac00000000",
3
"error": null,
4
"id": 1
5
}
6
\
© Tatum Technology, LLC