Channel accounts
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.
To avoid this, you can create separate channel accounts that can be used as the source account for the transaction and use the account holding the assets as the base account or the source account for the individual operations in the transaction. In this scenario, the assets will come out of the base account, and the sequence number and fees will be consumed by the channel account.
Channels take advantage of the fact that the source account of a transaction can be different than the source account of the operations inside the transaction. With this setup, you can make as many channels as you need to maintain your desired transaction rate.
You will, of course, have to sign the transaction with both the base account key and the channel account key.
For example:
- JavaScript
- 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
// create payment from baseAccount to customerAddress
var transaction = new StellarSdk.TransactionBuilder(
channelAccounts[channelIndex],
{
fee: StellarSdk.BASE_FEE,
networkPassphrase: StellarSdk.Networks.TESTNET,
},
)
.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
# 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
Guides in this category:
ποΈ Create an account
Learn about creating Stellar accounts, keypairs, funding, and account basics.
ποΈ Send to and receive payments from Contract Accounts
Learn to send payments to and receive payments from Contract Accounts on the Stellar network.
ποΈ Send and receive payments
Learn to send payments and watch for received payments on the Stellar network.
ποΈ Channel accounts
Create channel accounts to submit transactions to the network at a high rate.
ποΈ Claimable balances
Split a payment into two parts by creating a claimable balance.
ποΈ Clawbacks
Use clawbacks to burn a specific amount of a clawback-enabled asset from a trustline or claimable balance.
ποΈ Fee-bump transactions
Use fee-bump transactions to pay for transaction fees on behalf of another account without re-signing the transaction.
ποΈ Sponsored reserves
Use sponsored reserves to pay for base reserves on behalf of another account.
ποΈ Path payments
Send a payment where the asset received differs from the asset sent.
ποΈ Pooled accounts: muxed accounts and memos
Use muxed accounts to differentiate between individual accounts in a pooled account.
ποΈ Install and deploy a smart contract with code
Install and deploy a smart contract with code.
ποΈ Invoke a contract function in a transaction using SDKs
Use the Stellar SDK to create, simulate, and assemble a transaction.
ποΈ simulateTransaction RPC method guide
simulateTransaction examples and tutorials guide.
ποΈ Submit a transaction to Stellar RPC using the JavaScript SDK
Use a looping mechanism to submit a transaction to the RPC.
ποΈ Upload WebAssembly (Wasm) bytecode using code
Upload the Wasm of the contract using js-stellar-sdk.