XRP — ledger, Methods (2/2)
API reference for XRP. All methods ->
Part 2 of 2: 1 · 2
ledger_entry
Returns
The response follows the standard format, with a successful result containing the following fields:
index(string): The unique ID of this ledger entry.ledger_index(unsigned integer): The ledger index of the ledger that was used when retrieving this data.node(object; omitted if"binary": true): Object containing the data of this ledger entry, according to the ledger format.node_binary(string; omitted unless"binary": true): The binary representation of the ledger object, as hexadecimal.deleted_ledger_index(string; Clio server only): Returned if include_deleted parameter is set. The ledger index where the ledger entry object was deleted.
Transaction Methods:
Transactions are the only thing that can modify the shared state of the XRP Ledger. All business on the XRP Ledger takes the form of transactions. Use these methods to work with transactions.
simulate
Executes a dry run of any transaction type to preview results and metadata.
The simulate method executes a dry run of any transaction type, enabling you to preview the results and metadata of a transaction without committing them to the XRP Ledger. Since this command never submits a transaction to the network, it doesn't incur any fees.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON-RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):tx_blob(string; required): The transaction to simulate, in binary format. If you include this field, do not also includetx_json.tx_json(object; required): The transaction to simulate, in JSON format. If you include this field, do not also includetx_blob.binary(boolean; optional): The default value isfalse, which returns data and metadata in JSON format. Iftrue, returns data and metadata in binary format, serialized to a hexadecimal string.
Note:
- The simulated transaction must be unsigned.
- If the
Fee,Sequence,SigningPubKey, orNetworkIDfields are provided, they will be used in the transaction. Otherwise, the server will autofill them.
Returns
The response follows the standard format, with a successful result containing the following fields:
tx_json(object): The transaction that was simulated, including auto-filled values. Included ifbinarywasfalse.tx_blob(string): The serialized transaction that was simulated, including auto-filled values. Included ifbinarywastrue.ledger_index(ledger index): The ledger index of the ledger that would have included this transaction.meta(object): Transaction metadata, which describes the results of the transaction. Not included if the transaction fails with a code that means it wouldn’t be included in the ledger (such as a non-TEC code). Included ifbinarywasfalse.meta_blob(string): Transaction metadata, which describes the results of the transaction. Not included if the transaction fails with a code that means it wouldn’t be included in the ledger (such as a non-TEC code). Included ifbinarywastrue.
Request example
curl 'https://rpc.ankr.com/xrp_mainnet/YOUR_ANKR_API_KEY' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "simulate",
"params": [
{
"tx_json": {
"TransactionType": "Payment",
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
"Amount": {
"currency": "USD",
"value": "1",
"issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"
}
}
}
]
}'
Response example
{
"result": {
"applied": false,
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The simulated transaction would have been applied.",
"ledger_index": 100512217,
"meta": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"AccountTxnID": "42BDE75B7309C46BBA7FFC867DDA29DFCB2C066AA3866CF9076280A2DE63FE3C",
"Balance": "1138222640",
"Domain": "6D64756F31332E636F6D",
"EmailHash": "98B4375E1D753E5B91627516F6D70977",
"Flags": 9568256,
"MessageKey": "0000000000000000000000070000000300",
"OwnerCount": 17,
"RegularKey": "rD9iJmieYHn8jTtPjwwkW2Wm9sVDvPXLoJ",
"Sequence": 394,
"TicketCount": 5,
"TransferRate": 4294967295
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "13F1A95D7AAB7108D5CE7EEAF504B2894B8C674E6D68499076441C4837282BF8",
"PreviousFields": {
"AccountTxnID": "932CC7E9BAC1F7B9FA5381679F293EEC0A646E5E7F2F6D14C85FEE2102F0E66C",
"Balance": "1138222650",
"Sequence": 393
},
"PreviousTxnID": "E5C3578BDBEBDCDE7E1697E3BA6A1CF04B17CCEBDE4939200680FEF530C7978E",
"PreviousTxnLgrSeq": 94448149
}
}
],
"TransactionIndex": 126,
"TransactionResult": "tesSUCCESS"
},
"status": "success",
"tx_json": {
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Amount": {
"currency": "USD",
"issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"value": "1"
},
"Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
"Fee": "10",
"Sequence": 393,
"SigningPubKey": "",
"TransactionType": "Payment",
"TxnSignature": "",
"hash": "42BDE75B7309C46BBA7FFC867DDA29DFCB2C066AA3866CF9076280A2DE63FE3C"
}
}
}