Skip to main content

Exchanges

Exchanges are Transactions that move amounts between balances in the same Wallet. They can be used, for example, to exchange a cash balance for gems or the other way around.

Exchange Funds

let exchange = await solidtx.exchanges.create({
walletId: 'wallet_yxeh6q5mmpik8w6cyvc9zcnn',

sourceBalanceId: 'cash',
sourceAmount: '-10',

destinationBalanceId: 'gems',
destinationAmount: '500'
})

Parameters


walletId stringRequired

ID of the Wallet


sourceBalanceId stringRequired

ID of the source Balance


sourceAmount stringRequired
The amount to add to the source balance

destinationBalanceId stringRequired

ID of the destination Balance


destinationAmount stringRequired
The amount to add to the destination balance

Returns

Creates and returns the resulting transactions.

{
"id": "exchange_cm8p6demf00040cl6228g3k44",
"walletId": "wallet_yxeh6q5mmpik8w6cyvc9zcnn",
"createdAt": "2025-01-01T12:00:00Z",
"sourceTransaction": {
"id": "transaction_cm8p024g600010cl77lq6ahqa",
"walletId": "wallet_yxeh6q5mmpik8w6cyvc9zcnn",
"balanceId": "cash",
"type": "EXCHANGE",
"amount": "-10"
},
"destinationTransaction": {
"id": "transaction_cm8p6bhjg00030cl65yp07f0h",
"walletId": "wallet_yxeh6q5mmpik8w6cyvc9zcnn",
"balanceId": "gems",
"type": "EXCHANGE",
"amount": "100"
}
}