4️⃣Transactions: API
Last updated
Last updated
Transactions are the building material of every blockchain.
Transactions allow users to submit data to the blockchain which allows user to perform actions such as transferring DeSo, creating posts and profiles, and minting NFTs.
Transactions have three steps in their lifecycle
Construct: The first step for a developer is to interact with the DeSo Backend API through a transaction construction endpoint to get an unsigned user transaction. Social Transactions API, NFT Transactions API, Financial Transactions API, and Derived Keys Transaction API explain the endpoints that will get you an unsigned transaction.
Sign: The developer will then take the output TransactionHex
from the construct step's response, which encodes the user transaction, and signs it using DeSo Identity.
You can read about signing transactions in the section of the Endpoints documentation.
Broadcast: The signed transaction will be sent through the /api/v0/submit-transaction
by the developer so that it can be added to the blockchain ledger.
The Submit a transaction submit explains how this endpoint works.
You can read more about Transactions in this section of the Identity documentation.
POST
/api/v0/submit-transaction
Submit a signed transaction to DeSo blockchain.
Endpoint implementation in backend.
Example usages in frontend: - Make request to Submit Transaction - Use Submit Transaction in conjunction with signing transaction
Name | Type | Description |
---|---|---|
POST
/api/v0/get-txn
Check if transaction is currently in mempool. This is particularly useful if you need to wait for a transaction to be broadcasted before submitting a subsequent transaction.
Endpoint implementation in backend.
Example usages in frontend: - Make request to Get Txn - Use Get Txn to see if a transaction has been broadcast to the network
POST
/api/v0/append-extra-data
Append custom ExtraData for a given transaction hex. This endpoint is typically used when signing with a derived key.
Note: If you will be using this endpoint, you will need to increase MinFeeRateNanosPerKB to 1500 when using a transaction construction endpoint.
Endpoint implementation in backend
POST
/api/v0/get-transaction-spending
Calculates the total transaction spending by subtracting transaction output to sender from transaction inputs. This allows a convenient way to display to users how much they will spend if they submit a given transaction to the network.
Endpoint implementation in backend
Example usages in identity: - Make request to Get Transaction Spending - Use Get Transaction Spending to show user total spending of transaction
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Transaction
Transaction object
transaction object that was broadcast to the DeSo blockchain
PublicKey
string
Attribute of transaction
Public key of transactor
TxnTypeJSON
integer
Attribute of transaction
Number representing transaction type
ExtraData
map[string]string
Attribute of transaction
Arbitrary key value map providing metadata about the transaction
Signature
{ R: integer, S: integer }
Attribute of transaction
Signature of transactoin
TxInputs
Array of transaction iputs
[{ Index: integer, TxId: integer[] }]
Attribute of transaction
Each element represents an input (DeSo being used) in the transaction.
TxOutputs
Array of transaction outputs
[{ PublicKey: string, AmountNanos: integer }]
Attribute of transaction
Each element represents an output (DeSo being received) in the transaction
TxnMeta
Transaction Metadata object
Attribute of transaction
Transaction Metadata descriptions coming soon. Each transaction type has its own transaction metadata object structure.
TxnHashHex
String
Hex of transaction hash broadcasted to the DeSo blockchain
PostEntryResponse
PostEntryResponse
If a transaction is a submit post transaction, the PostEntryResponse
that was created by the transaction is included
TransactionHashHex*
Strng
Hex of Transaction hash that we want to check made it to the mempool
TxnFound
boolean
If true, the transaction is currently in the mempool
TransactionHex*
String
The hex of the transaction on which extra data will be appended.
ExtraData*
map[string]string
Arbitrary key value map that will be merged with any extra data decoded from TransactionHex. Keys from this map will overwrite keys that were decoded from TransactionHex
TransactionHex
string
hex of transaction with extra data appended
TransactionHex*
String
The hex of the transaction on which extra data will be appended.
TotalSpendingNanos
Integer
Total amount spent by the transactor in this transaction
TransactionHex*
String
Hex of transaction