Tutorials
Order exchange
Learn how to implement an order exchange with Blnk.
An order exchange holds each side until the orders match, then settles them. Alice offers 1,000 USDC for 0.01 BTC, and Bob offers 0.01 BTC for 1,000 USDC.
This tutorial shows how to implement that with Blnk.
Step
Design the money movement
Before we start building, we need to define our money movement. This helps us outline how the two orders meet.
Alice’s USDC is held in @USDC_Escrow, and Bob’s BTC is held in @BTC_Escrow. Both holds are inflight, so the funds stay reserved until the orders match.
Settlement commits those holds, then moves the BTC from escrow to Alice and the USDC from escrow to Bob.
Step
Create the USDC ledger
Before we start recording transactions, we need a ledger for USDC balances, separate from BTC. Each currency stays in its own ledger so the balances roll up on their own.
The escrow balances are created in the General Ledger when the orders are placed.
Create the USDC ledger:
curl -X POST "CORE_URL/ledgers" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "{{name}}",
"meta_data": {
"description": "{{description}}"
}
}'const response = await blnk.Ledgers.create({
name: '{{name}}',
meta_data: {
description: '{{description}}',
},
});ledger, _, _ := client.Ledger.Create(blnkgo.CreateLedgerRequest{
Name: "{{name}}",
MetaData: blnkgo.MetaData{
"description": "{{description}}",
},
})response = blnk.ledgers.create({
"name": "{{name}}",
"meta_data": {
"description": "{{description}}",
},
})ApiResponse<JsonNode> response = blnk.ledgers().create(
CreateLedger.create()
.name("{{name}}")
.metaData(Map.of(
"description", "{{description}}"
)));Step
Create the BTC ledger
BTC balances sit in their own ledger, for the same reason USDC does. Bob’s BTC and the BTC Alice receives both use this ledger.
Create the BTC ledger:
curl -X POST "CORE_URL/ledgers" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "{{name}}",
"meta_data": {
"description": "{{description}}"
}
}'const response = await blnk.Ledgers.create({
name: '{{name}}',
meta_data: {
description: '{{description}}',
},
});ledger, _, _ := client.Ledger.Create(blnkgo.CreateLedgerRequest{
Name: "{{name}}",
MetaData: blnkgo.MetaData{
"description": "{{description}}",
},
})response = blnk.ledgers.create({
"name": "{{name}}",
"meta_data": {
"description": "{{description}}",
},
})ApiResponse<JsonNode> response = blnk.ledgers().create(
CreateLedger.create()
.name("{{name}}")
.metaData(Map.of(
"description", "{{description}}"
)));Step
Create Alice's identity
An identity is how we record the customer. We pass Alice’s type, name, email, and phone number.
Anything else we want to keep goes in metadata. We’ll store her customer id there as customer_id. Her USDC and BTC balances both use this identity.
Create Alice’s identity:
curl -X POST "CORE_URL/identities" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"identity_type": "individual",
"first_name": "{{first_name}}",
"last_name": "{{last_name}}",
"email_address": "{{email_address}}",
"phone_number": "{{phone_number}}",
"meta_data": {
"customer_id": "{{customer_id}}"
}
}'const response = await blnk.Identity.create({
identity_type: 'individual',
first_name: '{{first_name}}',
last_name: '{{last_name}}',
email_address: '{{email_address}}',
phone_number: '{{phone_number}}',
meta_data: {
customer_id: '{{customer_id}}',
},
});identity, _, _ := client.Identity.Create(blnkgo.Identity{
IdentityType: blnkgo.Individual,
FirstName: "{{first_name}}",
LastName: "{{last_name}}",
EmailAddress: "{{email_address}}",
PhoneNumber: "{{phone_number}}",
MetaData: blnkgo.MetaData{
"customer_id": "{{customer_id}}",
},
})response = blnk.identity.create({
"identity_type": "individual",
"first_name": "{{first_name}}",
"last_name": "{{last_name}}",
"email_address": "{{email_address}}",
"phone_number": "{{phone_number}}",
"meta_data": {
"customer_id": "{{customer_id}}",
},
})ApiResponse<JsonNode> response = blnk.identity().create(
IdentityData.create()
.identityType("individual")
.firstName("{{first_name}}")
.lastName("{{last_name}}")
.emailAddress("{{email_address}}")
.phoneNumber("{{phone_number}}")
.metaData(Map.of("customer_id", "{{customer_id}}")));Step
Create Bob's identity
Bob is the other side of the trade. We record him the same way, with his own customer id, so his balances are not attached to Alice.
Create Bob’s identity:
curl -X POST "CORE_URL/identities" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"identity_type": "individual",
"first_name": "{{first_name}}",
"last_name": "{{last_name}}",
"email_address": "{{email_address}}",
"phone_number": "{{phone_number}}",
"meta_data": {
"customer_id": "{{customer_id}}"
}
}'const response = await blnk.Identity.create({
identity_type: 'individual',
first_name: '{{first_name}}',
last_name: '{{last_name}}',
email_address: '{{email_address}}',
phone_number: '{{phone_number}}',
meta_data: {
customer_id: '{{customer_id}}',
},
});identity, _, _ := client.Identity.Create(blnkgo.Identity{
IdentityType: blnkgo.Individual,
FirstName: "{{first_name}}",
LastName: "{{last_name}}",
EmailAddress: "{{email_address}}",
PhoneNumber: "{{phone_number}}",
MetaData: blnkgo.MetaData{
"customer_id": "{{customer_id}}",
},
})response = blnk.identity.create({
"identity_type": "individual",
"first_name": "{{first_name}}",
"last_name": "{{last_name}}",
"email_address": "{{email_address}}",
"phone_number": "{{phone_number}}",
"meta_data": {
"customer_id": "{{customer_id}}",
},
})ApiResponse<JsonNode> response = blnk.identity().create(
IdentityData.create()
.identityType("individual")
.firstName("{{first_name}}")
.lastName("{{last_name}}")
.emailAddress("{{email_address}}")
.phoneNumber("{{phone_number}}")
.metaData(Map.of("customer_id", "{{customer_id}}")));Step
Create Alice's USDC balance
Alice spends from this balance. It sits on the USDC ledger and uses her identity.
Create Alice’s USDC balance:
curl -X POST "CORE_URL/balances" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}"
}'const response = await blnk.LedgerBalances.create({
ledger_id: '{{ledger_id}}',
identity_id: '{{identity_id}}',
currency: '{{currency}}',
});balance, _, _ := client.LedgerBalance.Create(blnkgo.CreateLedgerBalanceRequest{
LedgerID: "{{ledger_id}}",
IdentityID: "{{identity_id}}",
Currency: "{{currency}}",
})response = blnk.ledger_balances.create({
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}",
})ApiResponse<JsonNode> response = blnk.ledgerBalances().create(
CreateLedgerBalance.create()
.ledgerId("{{ledger_id}}")
.identityId("{{identity_id}}")
.currency("{{currency}}"));Step
Create Alice's BTC balance
This is where Alice receives the 0.01 BTC. It sits on the BTC ledger and uses her identity.
Create Alice’s BTC balance:
curl -X POST "CORE_URL/balances" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}"
}'const response = await blnk.LedgerBalances.create({
ledger_id: '{{ledger_id}}',
identity_id: '{{identity_id}}',
currency: '{{currency}}',
});balance, _, _ := client.LedgerBalance.Create(blnkgo.CreateLedgerBalanceRequest{
LedgerID: "{{ledger_id}}",
IdentityID: "{{identity_id}}",
Currency: "{{currency}}",
})response = blnk.ledger_balances.create({
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}",
})ApiResponse<JsonNode> response = blnk.ledgerBalances().create(
CreateLedgerBalance.create()
.ledgerId("{{ledger_id}}")
.identityId("{{identity_id}}")
.currency("{{currency}}"));Step
Create Bob's USDC balance
This is where Bob receives the 1,000 USDC. It sits on the USDC ledger and uses his identity.
Create Bob’s USDC balance:
curl -X POST "CORE_URL/balances" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}"
}'const response = await blnk.LedgerBalances.create({
ledger_id: '{{ledger_id}}',
identity_id: '{{identity_id}}',
currency: '{{currency}}',
});balance, _, _ := client.LedgerBalance.Create(blnkgo.CreateLedgerBalanceRequest{
LedgerID: "{{ledger_id}}",
IdentityID: "{{identity_id}}",
Currency: "{{currency}}",
})response = blnk.ledger_balances.create({
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}",
})ApiResponse<JsonNode> response = blnk.ledgerBalances().create(
CreateLedgerBalance.create()
.ledgerId("{{ledger_id}}")
.identityId("{{identity_id}}")
.currency("{{currency}}"));Step
Create Bob's BTC balance
Bob spends from this balance. It sits on the BTC ledger and uses his identity.
Create Bob’s BTC balance:
curl -X POST "CORE_URL/balances" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}"
}'const response = await blnk.LedgerBalances.create({
ledger_id: '{{ledger_id}}',
identity_id: '{{identity_id}}',
currency: '{{currency}}',
});balance, _, _ := client.LedgerBalance.Create(blnkgo.CreateLedgerBalanceRequest{
LedgerID: "{{ledger_id}}",
IdentityID: "{{identity_id}}",
Currency: "{{currency}}",
})response = blnk.ledger_balances.create({
"ledger_id": "{{ledger_id}}",
"identity_id": "{{identity_id}}",
"currency": "{{currency}}",
})ApiResponse<JsonNode> response = blnk.ledgerBalances().create(
CreateLedgerBalance.create()
.ledgerId("{{ledger_id}}")
.identityId("{{identity_id}}")
.currency("{{currency}}"));Step
Fund Alice's USDC
Alice starts with 1,000 USDC, funded from @USDC_FundingPool. USDC has 6 decimal places, so precision is 1000000, and 1,000 USDC is precise_amount 1000000000.
Fund Alice’s USDC:
curl -X POST "CORE_URL/transactions" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"precise_amount": {{precise_amount}},
"precision": 1000000,
"reference": "ORD-USDC-20261019-090000",
"description": "Initial USDC funding",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"allow_overdraft": true
}'const amount = {{amount}};
const precision = 1000000;
const precise_amount = Math.round(amount * precision);
const response = await blnk.Transactions.create({
precise_amount,
precision,
reference: 'ORD-USDC-20261019-090000',
description: 'Initial USDC funding',
currency: '{{currency}}',
source: '{{source}}',
destination: '{{destination}}',
allow_overdraft: true,
});amount := {{amount}}
precision := 1000000
preciseAmount := big.NewInt(int64(math.Round(amount * float64(precision))))
transaction, _, _ := client.Transaction.Create(blnkgo.CreateTransactionRequest{
ParentTransaction: blnkgo.ParentTransaction{
PreciseAmount: preciseAmount,
Precision: precision,
Reference: "ORD-USDC-20261019-090000",
Description: "Initial USDC funding",
Currency: "{{currency}}",
Source: "{{source}}",
Destination: "{{destination}}",
},
AllowOverdraft: true,
})amount = {{amount}}
precision = 1000000
precise_amount = round(amount * precision)
response = blnk.transactions.create({
"precise_amount": precise_amount,
"precision": precision,
"reference": "ORD-USDC-20261019-090000",
"description": "Initial USDC funding",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"allow_overdraft": True,
})double amount = {{amount}};
int precision = 1000000;
int preciseAmount = (int) Math.round(amount * precision);
ApiResponse<JsonNode> response = blnk.transactions().create(
CreateTransactions.create()
.preciseAmount(preciseAmount)
.precision(precision)
.reference("ORD-USDC-20261019-090000")
.description("Initial USDC funding")
.currency("{{currency}}")
.source("{{source}}")
.destination("{{destination}}")
.allowOverdraft(true));Step
Fund Bob's BTC
Bob starts with 0.01 BTC, funded from @BTC_FundingPool. BTC is stored in satoshis, so precision is 100000000, and 0.01 BTC is precise_amount 1000000. Overdraft is on for the same reason as the USDC funding.
Fund Bob’s BTC:
curl -X POST "CORE_URL/transactions" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"precise_amount": {{precise_amount}},
"precision": 100000000,
"reference": "ORD-BTC-20261019-090000",
"description": "Initial BTC funding",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"allow_overdraft": true
}'const amount = {{amount}};
const precision = 100000000;
const precise_amount = Math.round(amount * precision);
const response = await blnk.Transactions.create({
precise_amount,
precision,
reference: 'ORD-BTC-20261019-090000',
description: 'Initial BTC funding',
currency: '{{currency}}',
source: '{{source}}',
destination: '{{destination}}',
allow_overdraft: true,
});amount := {{amount}}
precision := 100000000
preciseAmount := big.NewInt(int64(math.Round(amount * float64(precision))))
transaction, _, _ := client.Transaction.Create(blnkgo.CreateTransactionRequest{
ParentTransaction: blnkgo.ParentTransaction{
PreciseAmount: preciseAmount,
Precision: precision,
Reference: "ORD-BTC-20261019-090000",
Description: "Initial BTC funding",
Currency: "{{currency}}",
Source: "{{source}}",
Destination: "{{destination}}",
},
AllowOverdraft: true,
})amount = {{amount}}
precision = 100000000
precise_amount = round(amount * precision)
response = blnk.transactions.create({
"precise_amount": precise_amount,
"precision": precision,
"reference": "ORD-BTC-20261019-090000",
"description": "Initial BTC funding",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"allow_overdraft": True,
})double amount = {{amount}};
int precision = 100000000;
int preciseAmount = (int) Math.round(amount * precision);
ApiResponse<JsonNode> response = blnk.transactions().create(
CreateTransactions.create()
.preciseAmount(preciseAmount)
.precision(precision)
.reference("ORD-BTC-20261019-090000")
.description("Initial BTC funding")
.currency("{{currency}}")
.source("{{source}}")
.destination("{{destination}}")
.allowOverdraft(true));Step
Place Alice's order
Alice offers 1,000 USDC. We record an inflight transaction from her USDC balance to @USDC_Escrow, which reserves the USDC until the order is matched or voided.
Place Alice’s order:
curl -X POST "CORE_URL/transactions" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"precise_amount": {{precise_amount}},
"precision": 1000000,
"reference": "ORD-ALICE-20261019-103000",
"description": "Exchange order",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"inflight": true
}'const amount = {{amount}};
const precision = 1000000;
const precise_amount = Math.round(amount * precision);
const response = await blnk.Transactions.create({
precise_amount,
precision,
reference: 'ORD-ALICE-20261019-103000',
description: 'Exchange order',
currency: '{{currency}}',
source: '{{source}}',
destination: '{{destination}}',
inflight: true,
});amount := {{amount}}
precision := 1000000
preciseAmount := big.NewInt(int64(math.Round(amount * float64(precision))))
transaction, _, _ := client.Transaction.Create(blnkgo.CreateTransactionRequest{
ParentTransaction: blnkgo.ParentTransaction{
PreciseAmount: preciseAmount,
Precision: precision,
Reference: "ORD-ALICE-20261019-103000",
Description: "Exchange order",
Currency: "{{currency}}",
Source: "{{source}}",
Destination: "{{destination}}",
},
Inflight: true,
})amount = {{amount}}
precision = 1000000
precise_amount = round(amount * precision)
response = blnk.transactions.create({
"precise_amount": precise_amount,
"precision": precision,
"reference": "ORD-ALICE-20261019-103000",
"description": "Exchange order",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"inflight": True,
})double amount = {{amount}};
int precision = 1000000;
int preciseAmount = (int) Math.round(amount * precision);
ApiResponse<JsonNode> response = blnk.transactions().create(
CreateTransactions.create()
.preciseAmount(preciseAmount)
.precision(precision)
.reference("ORD-ALICE-20261019-103000")
.description("Exchange order")
.currency("{{currency}}")
.source("{{source}}")
.destination("{{destination}}")
.inflight(true));Step
Place Bob's order
Bob offers 0.01 BTC. We record an inflight transaction from his BTC balance to @BTC_Escrow.
Place Bob’s order:
curl -X POST "CORE_URL/transactions" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"precise_amount": {{precise_amount}},
"precision": 100000000,
"reference": "ORD-BOB-20261019-103000",
"description": "Exchange order",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"inflight": true
}'const amount = {{amount}};
const precision = 100000000;
const precise_amount = Math.round(amount * precision);
const response = await blnk.Transactions.create({
precise_amount,
precision,
reference: 'ORD-BOB-20261019-103000',
description: 'Exchange order',
currency: '{{currency}}',
source: '{{source}}',
destination: '{{destination}}',
inflight: true,
});amount := {{amount}}
precision := 100000000
preciseAmount := big.NewInt(int64(math.Round(amount * float64(precision))))
transaction, _, _ := client.Transaction.Create(blnkgo.CreateTransactionRequest{
ParentTransaction: blnkgo.ParentTransaction{
PreciseAmount: preciseAmount,
Precision: precision,
Reference: "ORD-BOB-20261019-103000",
Description: "Exchange order",
Currency: "{{currency}}",
Source: "{{source}}",
Destination: "{{destination}}",
},
Inflight: true,
})amount = {{amount}}
precision = 100000000
precise_amount = round(amount * precision)
response = blnk.transactions.create({
"precise_amount": precise_amount,
"precision": precision,
"reference": "ORD-BOB-20261019-103000",
"description": "Exchange order",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
"inflight": True,
})double amount = {{amount}};
int precision = 100000000;
int preciseAmount = (int) Math.round(amount * precision);
ApiResponse<JsonNode> response = blnk.transactions().create(
CreateTransactions.create()
.preciseAmount(preciseAmount)
.precision(precision)
.reference("ORD-BOB-20261019-103000")
.description("Exchange order")
.currency("{{currency}}")
.source("{{source}}")
.destination("{{destination}}")
.inflight(true));Step
Commit Alice's order
The orders match, so we commit Alice’s hold. That moves her 1,000 USDC into @USDC_Escrow.
Commit Alice’s order:
curl -X PUT "CORE_URL/transactions/inflight/{{transaction_id}}" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "commit"
}'const response = await blnk.Transactions.updateStatus(
'{{transaction_id}}',
{
status: 'commit',
},
);transaction, _, _ := client.Transaction.Update(
"{{transaction_id}}",
blnkgo.UpdateStatus{
Status: blnkgo.InflightStatusCommit,
},
)response = blnk.transactions.update_status(
"{{transaction_id}}",
{
"status": "commit",
},
)ApiResponse<JsonNode> response = blnk.transactions().updateStatus(
"{{transaction_id}}",
UpdateTransactionStatus.create()
.status("commit"));Step
Commit Bob's order
We commit Bob’s hold the same way. That moves his 0.01 BTC into @BTC_Escrow.
Commit Bob’s order:
curl -X PUT "CORE_URL/transactions/inflight/{{transaction_id}}" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "commit"
}'const response = await blnk.Transactions.updateStatus(
'{{transaction_id}}',
{
status: 'commit',
},
);transaction, _, _ := client.Transaction.Update(
"{{transaction_id}}",
blnkgo.UpdateStatus{
Status: blnkgo.InflightStatusCommit,
},
)response = blnk.transactions.update_status(
"{{transaction_id}}",
{
"status": "commit",
},
)ApiResponse<JsonNode> response = blnk.transactions().updateStatus(
"{{transaction_id}}",
UpdateTransactionStatus.create()
.status("commit"));Step
Settle the USDC
The USDC is in escrow, so we pay Bob. The source is @USDC_Escrow, and the destination is Bob’s USDC balance.
Wait until Alice’s commit is applied. This transfer does not turn on overdraft, so it fails if the escrow is still empty.
Settle the USDC:
curl -X POST "CORE_URL/transactions" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"precise_amount": {{precise_amount}},
"precision": 1000000,
"reference": "SET-USDC-20261019-103000",
"description": "USDC settlement",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}"
}'const amount = {{amount}};
const precision = 1000000;
const precise_amount = Math.round(amount * precision);
const response = await blnk.Transactions.create({
precise_amount,
precision,
reference: 'SET-USDC-20261019-103000',
description: 'USDC settlement',
currency: '{{currency}}',
source: '{{source}}',
destination: '{{destination}}',
});amount := {{amount}}
precision := 1000000
preciseAmount := big.NewInt(int64(math.Round(amount * float64(precision))))
transaction, _, _ := client.Transaction.Create(blnkgo.CreateTransactionRequest{
ParentTransaction: blnkgo.ParentTransaction{
PreciseAmount: preciseAmount,
Precision: precision,
Reference: "SET-USDC-20261019-103000",
Description: "USDC settlement",
Currency: "{{currency}}",
Source: "{{source}}",
Destination: "{{destination}}",
},
})amount = {{amount}}
precision = 1000000
precise_amount = round(amount * precision)
response = blnk.transactions.create({
"precise_amount": precise_amount,
"precision": precision,
"reference": "SET-USDC-20261019-103000",
"description": "USDC settlement",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
})double amount = {{amount}};
int precision = 1000000;
int preciseAmount = (int) Math.round(amount * precision);
ApiResponse<JsonNode> response = blnk.transactions().create(
CreateTransactions.create()
.preciseAmount(preciseAmount)
.precision(precision)
.reference("SET-USDC-20261019-103000")
.description("USDC settlement")
.currency("{{currency}}")
.source("{{source}}")
.destination("{{destination}}"));Step
Settle the BTC
The BTC is in escrow, so we pay Alice. The source is @BTC_Escrow, and the destination is Alice’s BTC balance.
Wait until Bob’s commit is applied before you record this transfer.
Settle the BTC:
curl -X POST "CORE_URL/transactions" \
-H "X-blnk-key: CORE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"precise_amount": {{precise_amount}},
"precision": 100000000,
"reference": "SET-BTC-20261019-103000",
"description": "BTC settlement",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}"
}'const amount = {{amount}};
const precision = 100000000;
const precise_amount = Math.round(amount * precision);
const response = await blnk.Transactions.create({
precise_amount,
precision,
reference: 'SET-BTC-20261019-103000',
description: 'BTC settlement',
currency: '{{currency}}',
source: '{{source}}',
destination: '{{destination}}',
});amount := {{amount}}
precision := 100000000
preciseAmount := big.NewInt(int64(math.Round(amount * float64(precision))))
transaction, _, _ := client.Transaction.Create(blnkgo.CreateTransactionRequest{
ParentTransaction: blnkgo.ParentTransaction{
PreciseAmount: preciseAmount,
Precision: precision,
Reference: "SET-BTC-20261019-103000",
Description: "BTC settlement",
Currency: "{{currency}}",
Source: "{{source}}",
Destination: "{{destination}}",
},
})amount = {{amount}}
precision = 100000000
precise_amount = round(amount * precision)
response = blnk.transactions.create({
"precise_amount": precise_amount,
"precision": precision,
"reference": "SET-BTC-20261019-103000",
"description": "BTC settlement",
"currency": "{{currency}}",
"source": "{{source}}",
"destination": "{{destination}}",
})double amount = {{amount}};
int precision = 100000000;
int preciseAmount = (int) Math.round(amount * precision);
ApiResponse<JsonNode> response = blnk.transactions().create(
CreateTransactions.create()
.preciseAmount(preciseAmount)
.precision(precision)
.reference("SET-BTC-20261019-103000")
.description("BTC settlement")
.currency("{{currency}}")
.source("{{source}}")
.destination("{{destination}}"));Step
Confirmation
When the commits and both settlements are applied, Alice has 0 USDC and 0.01 BTC. Bob has 1,000 USDC and 0 BTC. Both escrow balances are back to 0.
If you have a Blnk Cloud account or an Enterprise license, you can confirm this by checking the dashboard or using the CLI.
Print every balance:
blnk balances list