UNPKG

valor-sdk

Version:

valor-sdk is a library for working with the Valor Horizon server.

40 lines (30 loc) 1.63 kB
--- title: submitTransaction() --- ## Overview You can build a transaction locally (see [this example](../readme.md#building-transactions)), but after you build it you have to submit it to the Valor network. js-valor-sdk has a function `submitTransaction()` that sends your transaction to the Horizon server (via the [`transactions_create`](https://valorfoundation.org/developers/horizon/reference/transactions-create.html) endpoint) to be broadcast to the Valor network. ## Methods | Method | Horizon Endpoint | Param Type | Description | | --- | --- | --- | --- | | `submitTransaction(Transaction)` | [`transactions_create`](https://valorfoundation.org/developers/horizon/reference/transactions-create.html) | [`Transaction`](https://github.com/valorfoundation/js-valor-base/blob/master/src/transaction.js) | Submits a transaction to the network. ## Example ```js var VallorSdk = require('js-valor-sdk') var server = new VallorSdk.Server('https://dashboard.valorfoundation.org'); var transaction = new VallorSdk.TransactionBuilder(account) // this operation funds the new account with XLM .addOperation(VallorSdk.Operation.payment({ destination: "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", asset: VallorSdk.Asset.native(), amount: "20000000" })) .build(); transaction.sign(VallorSdk.Keypair.fromSeed(seedString)); // sign the transaction server.submitTransaction(transaction) .then(function (transactionResult) { console.log(transactionResult); }) .catch(function (err) { console.error(err); }); ```