Wallet API
Broadcast transaction

Broadcast transaction#

The server calls the POST /api/v5/waas/transaction/send-transaction API, and the transaction is broadcast to the chain, so that the user’s transaction information is recorded on the chain.

//Define your parameters
const postSendTransactionBody = {
    addrFrom: "0x238193be9e80e68eace3588b45d8cf4a7eae0fa3",
    addrTo: "0xe0f7a45f1aa6cfff6fbbb1049f7a8c9248312c2e",
    chainId: "56",
    walletId:"13886e05-1265-4b79-8ac3-b7ab46211001",
    signedTx: "0xf8aa6a84ee6b280083012e389455d398326f99059ff775485246999027b319795580b844a9059cbb000000000000000000000000e0f7a45f1aa6cfff6fbbb1049f7a8c9248312c2e00000000000000000000000000000000000000000000000000000002540be4008193a0dfecbffac07db267e7438fe94f48c0d30bb17c3d86774bd445a9d70d06a974e9a0363c583a80dfc099d3a4186ce943d4bb38420dd52e23d26d30a73bfa8e291ed9",
    txAmount: "10000000000",
    serviceCharge: "4128241194000",
    tokenAddress: "0x55d398326f99059ff775485246999027b3197955",
    txHash: "0x585efb06371c2827a8da7b3dc2f0d3daf4f61cd14959c928bc698c43822881c3",
    txType: "transfer",
    extJson: {
        gasPrice: "196582914",
        gasLimit: "21000",
        nonce: "578"
    }
   };

//Define auxiliary function
const sendTransactionData = async () => {
     const apiRequestUrl = getRequestUrl(
       apiBaseUrl,
       'api/v5/waas/transaction/send-transaction'
     );
     return fetch(apiRequestUrl, {
       method: 'post',
       headers: headersParams,
       body: JSON.stringify(postSendTransactionBody),
     })
       .then((res) => res.json())
       .then((res) => {
         return res;
       });
   };

const { data: sendTransactionData } = await sendTransactionData();

After sending the transaction, you will receive a response like this:

{
	"code": 0,
	"msg": "success",
	"data": [{
		"orderId": "469356614923743232"
	}]
}