Skip to main content

sendTransaction

Submit a real transaction to the Stellar network. This is the only way to make changes on-chain.

Unlike Horizon, this does not wait for transaction completion. It simply validates and enqueues the transaction. Clients should call getTransaction to learn about transaction success/failure.

This supports all transactions, not only smart contract-related transactions.

Params

(1)

Please note that parameter structure within the request must contain named parameters as a by-name object, and not as positional arguments in a by-position array

1. transaction (required)

The signed transaction to broadcast for inclusion in a ledger.

string

A Stellar transaction, serialized as a base64 string

Result

(sendTransactionResult)

Transaction status and network state. The result will include if the transaction was successfully enqueued, and information about the current ledger.

hash
string
required

Transaction hash (as a hex-encoded string)

>= 64 characters<= 64 characters
Match pattern:
^[a-f\d]{64}$
status
string
required

The current status of the transaction by hash.

Allowed values:
PENDINGDUPLICATETRY_AGAIN_LATERERROR
latestLedger
number
required

The sequence number of the latest ledger known to Soroban RPC at the time it handled the request.

latestLedgerCloseTime
string
required

The unix timestamp of the close time of the latest ledger known to Soroban RPC at the time it handled the request.

errorResultXdr
string

(optional) If the transaction status is ERROR, this will be a base64 encoded string of the raw TransactionResult XDR struct containing details on why stellar-core rejected the transaction.

diagnosticEventsXdr
array[string]

(optional) If the transaction status is ERROR, this field may be present with an array of base64 encoded strings. Each string will decode to a raw DiagnosticEvent XDR struct containing details on why stellar-core rejected the transaction.

Examples

Submitting a valid transaction using the sendTransaction method, resulting in a PENDING status.

Request

curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 8675309,
"method": "sendTransaction",
"params": {
"transaction": "AAAAAgAAAAAg4dbAxsGAGICfBG3iT2cKGYQ6hK4sJWzZ6or1C5v6GAAAAGQAJsOiAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACgAAAAVIZWxsbwAAAAAAAAEAAAAMU29yb2JhbiBEb2NzAAAAAAAAAAELm/oYAAAAQATr6Ghp/DNO7S6JjEFwcJ9a+dvI6NJr7I/2eQttvoovjQ8te4zKKaapC3mbmx6ld6YKL5T81mxs45TjzdG5zw0="
}
}' \
https://soroban-testnet.stellar.org | jq

Result

{
"jsonrpc": "2.0",
"id": 8675309,
"result": {
"status": "PENDING",
"hash": "d8ec9b68780314ffdfdfc2194b1b35dd27d7303c3bceaef6447e31631a1419dc",
"latestLedger": 2553978,
"latestLedgerCloseTime": "1700159337"
}
}

SDK Guide

The example above is sending a transaction using RPC methods directly. If you are using the Stellar SDK to build applications, you can use the native functions to get the same information.

# pip install --upgrade stellar-sdk
from stellar_sdk import SorobanServer, soroban_rpc, Account, Asset, Keypair, Network, TransactionBuilder

def send_transaction() -> soroban_rpc.SendTransactionResponse:
server = SorobanServer(server_url='https://soroban-testnet.stellar.org', client=None)

root_keypair = Keypair.from_secret(
"SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
)
root_account = server.load_account("GBSBL6FBPX5UHKL4AZCPUU6PXKUBYMKRUN3L4YQ4V2CCWSE7YMN2HYPB")
contract_id = "CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE"
transaction = (
TransactionBuilder(
source_account=root_account,
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
base_fee=100,
)
.append_invoke_contract_function_op(contract_id,"increment")
# mark this transaction as valid only for the next 30 seconds
.set_timeout(30)
.build()
)
transaction.sign(root_keypair)
response = server.send_transaction(transaction)
return response

response = send_transaction()

print("status", response.status)
print("hash:", response.hash);
print("status:", response.status);
print("errorResultXdr:", response.error_result_xdr);