Submit transaction

Even though we've signed the transaction, until the signed message reaches the network, no changes will occur. Once we submit the transaction, we need to wait for the validators to confirm it. When the validators approve the transaction, ledger values will change and account balances will be updated. The following function takes signed transaction as input and submits it to the network:

api.submit(signedTransaction).then(onSuccess,onFailure);

In the following lines, we've put together the code to prepare, sign, and submit the transaction. As you can see, we wait for each step to return a response before we continue to the next step:

api.connect().then(() => { console.log('Connected to the test network.');return api.preparePayment(sourceAddress, ...

Get Ripple Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.