This document explains how to broadcast a signed transaction using the Qubic HTTP RPC endpoint and SCAPI helpers.
POST /v1/broadcast-transaction
Default base URL in SCAPI:
https://rpc.qubic.org/live/v1/- Can be overridden with
QUBIC_RPC_BASE_URL
Full URL example:
https://rpc.qubic.org/live/v1/broadcast-transaction
{
"encodedTransaction": "<BASE64_RAW_TX>"
}Where:
encodedTransactionis Base64 of the raw binary transaction bytes (not hex).
{
"peersBroadcasted": 3,
"encodedTransaction": "<BASE64_RAW_TX>",
"transactionId": "<tx_id>"
}peersBroadcasted(int32): number of peers the node broadcasted the transaction toencodedTransaction(string): base64 transaction echoed by servertransactionId(string): transaction hash / id
use scapi::{PayloadBuilder, QubicId, QubicWallet, build_ticket_tx_bytes};
let wallet = QubicWallet::from_seed("...")?;
let to = QubicId::from_contract_id(16);
let payload = PayloadBuilder::new().to_bytes();
let tx_bytes = build_ticket_tx_bytes(&wallet, to, 1_000_000, 12345, 1, payload)?;Or, if you only have the seed:
use scapi::{PayloadBuilder, QubicId, build_ticket_tx_bytes_from_seed};
let to = QubicId::from_contract_id(16);
let payload = PayloadBuilder::new().to_bytes();
let tx_bytes = build_ticket_tx_bytes_from_seed("...", to, 1_000_000, 12345, 1, payload)?;use scapi::rpc::post::broadcast_transaction_bytes;
let response = broadcast_transaction_bytes(&tx_bytes).await?;
println!("Peers: {}", response.peers_broadcasted);
println!("Tx ID: {}", response.transaction_id);- Make sure
tickis set to a future tick (commonlycurrent_tick + 5). - For contract procedures, set:
to= contract id (QubicId::from_contract_id(...))input_type= procedure indexpayload= procedure input bytes
- You can fetch current tick via:
GET /v1/tick-infoorscapi::rpc::get::get_tick_info()