After posting a transaction to the network, most software needs to display comprehensive feedback to the user. This is especially true when an error happens.
This library produces human-readable descriptions for any possible code Stellar Core returns:
const response = await server.submitTransaction(transaction)
const result = new TxResult(response)
Result for successful transactions:
{
validated: true,
title: "The transaction has been validated",
hash: "d89c...007e",
ledger: 370369,
offerResults: undefined,
link: "https://horizon-testnet.stellar.org/transactions/d89c...007e"
}
Note: offerResults
is as described in StellarSdk server.submitTransaction() documentation.
Result for failed transactions:
{
validated: false,
title: "The transaction has been rejected",
errors: [
"Operation 1: The destination account doesn't exist.",
"Operation 3: The source does not have enough funds."
]
}
NPM | Yarn | Documentation