Send Transaction
Most Trustless Work endpoints return an unsigned transaction in XDR format. This endpoint is used to sign such unsigned transactions and send them to the Stellar network.
Headers
Name
Value
Content-Type
application/json
Authorization
Bearer <token>
Open API
post
Body
signedXdrstringRequiredExample:
The sign's hash. This come from the wallet
AAAAAgAAAAB...
Responses
200
The transaction has been successfully sent to the Stellar network
application/json
400
Bad request
401
Unauthorized access
429
Too Many Requests
500
Possible errors:
- The transaction could not be sent to the Stellar network for some unknown reason. Please try again.
application/json
post
POST /helper/send-transaction HTTP/1.1
Host:
Content-Type: application/json
Accept: */*
Content-Length: 30
{
"signedXdr": "AAAAAgAAAAB..."
}
{
"status": "SUCCESS",
"message": "The transaction has been successfully sent to the Stellar network.",
"contractId": "CAATN5D...",
"escrow": {
"amount": 50,
"roles": {
"approver": "GAWVVSA...",
"serviceProvider": "GAWVVSA6...",
"disputeResolver": "GAWVVSA...",
"receiver": "GAWVVSA...",
"platformAddress": "GAWVVSA...",
"releaseSigner": "GAWVVSA..."
},
"flags": {
"disputed": false,
"released": false,
"resolved": false
},
"description": "This is a sample TW escrow for testing purposes",
"engagementId": "ENG12345",
"milestones": [
{
"approved": false,
"description": "Initial milestone",
"evidence": "",
"status": "pending"
},
{
"approved": false,
"description": "Second milestone",
"evidence": "",
"status": "pending"
}
],
"platformFee": 500,
"title": "Sample TW Escrow",
"trustline": {
"address": "CBIELTK...",
"decimals": 10000000
},
"receiverMemo": 90909090
}
}
Use Example:
import axios from "axios";
const http = axios.create({
baseURL: "https://dev.api.trustlesswork.com",
timeout: 10000,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer your_api_key`,
},
});
export const useExample = async () => {
// Get the signer address
const { address } = await kit.getAddress();
const response = await http.post(
"/any-endpoint",
{
// body requested for the endpoint
},
);
// Get the unsigned transaction hash
const { unsignedTransaction } = response.data;
// Sign the transaction by wallet
const { signedTxXdr } = await signTransaction(unsignedTransaction, {
address,
networkPassphrase: WalletNetwork.TESTNET,
});
// Send the transaction to Stellar Network <--------------- THIS
const tx = await http.post("/helper/send-transaction", {
signedXdr: signedTxXdr,
});
const { data } = tx;
return data;
}
Last updated
Was this helpful?