Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion docs/encyclopedia/channel-accounts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Channel Accounts
---

import { CodeExample } from "@site/src/components/CodeExample";

Channel accounts provide a method for submitting transactions to the network at a high rate.

An account’s transactions always need to be submitted to the network in increments of one sequence number (unless minimum sequence number preconditions are set). This can cause problems if you are submitting transactions at a high rate, as they can potentially reach Stellar Core out of order and will then bounce with a bad sequence error.
Expand All @@ -14,4 +16,57 @@ You will, of course, have to sign the transaction with both the base account key

For example:

[insert code]
<CodeExample>

```js
StellarSdk.Network.useTestNetwork();
// channelAccounts[] is an array of accountIDs, one for each channel
// channelKeys[] is an array of secret keys, one for each channel
// channelIndex is the channel you want to send this transaction over

// create payment from baseAccount to customerAddress
var transaction = new StellarSdk.TransactionBuilder(
channelAccounts[channelIndex],
)
.addOperation(
StellarSdk.Operation.payment({
source: baseAccount.address(),
destination: customerAddress,
asset: StellarSdk.Asset.native(),
amount: amountToSend,
}),
)
// Wait a maximum of three minutes for the transaction
.setTimeout(180)
.build();

transaction.sign(baseAccountKey); // base account must sign to approve the payment
transaction.sign(channelKeys[channelIndex]); // channel must sign to approve it being the source of the transaction
```

```python
# channelAccounts[] is an array of accountIDs, one for each channel
# channelKeys[] is an array of secret keys, one for each channel
# channelIndex is the channel you want to send this transaction over

transaction = (
TransactionBuilder(
source_account=channelAccounts[channelIndex],
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
base_fee=base_fee,
)
.append_payment_op(
source=baseAccount.public_key,
destination=customerAddress,
asset=Asset.native(),
amount=amountToSend,
)
.set_timeout(180) # Wait a maximum of three minutes for the transaction
.build()
)

transaction.sign(baseAccountKey) # base account must sign to approve the payment
transaction.sign(channelKeys[channelIndex]) # channel must sign to approve it being the source of the transaction
```
</CodeExample>