Transfers
Overview
Transfers is the method of sending funds from one account to another. Each transfer on the DRM ledger consists of multiple transfer steps which contain the following fields:
from_account
- the senderto_account
- the receiver- The amount
- A metadata field for unstructured data
Generally, these transfers are formatted as protobufs.
Note: All transfer steps are applied atomically; that is, if one step fails, all the steps fail.
Transfer Steps
Since each transfer consists of multiple "steps", you can send funds to multiple accounts in one atomic action.
An example use case is transaction fees since they are typically paid to an account different from the to_account
. To collect transaction fees, you would create a single transfer with two steps. One step for the main transfer (i.e., Alice's account to Bob's account), and a second transfer for the fee (i.e., Alice's account to the fee account). The entire transfer will fail if Alice lacks the funds to complete either step.
Transfer Hops
Since the DRM ledger is hierarchical, transfers have unique behavior. For example, you have an account structure with two banks: Iron Bank and Tungsten Bank where Tungsten Bank has a customer named Alice, and Iron Bank has a customer named Chris.
In banking, payments between two banks are typically settled in central bank money (reserves), reducing counterparty risk. The DRM platform follows a similar model for the settlement of fund transfers. The DRM ledger makes this process seamless. When Alice transfers funds to Chris, the ledger performs several different hops behind the scenes.
A Hop is an internal ledger procedure that the DRM ledger uses to ensure the flow of funds between accounts.
A Transfer step bundles multiple transfers into a single operation, enhancing the DRM ledger's efficiency.
The relationship is Transfer -> Transfer Step -> Hop
.
You never create hops with the DRM API. The ledger itself handles it.
Using the same example as above, the steps would be:
- Alice's M1 money (bank deposits) is transferred to Tungsten Bank.
- Tungsten Bank transfers M0 money from its holdings, through the root account, to Iron Bank.
- Iron Bank has now been credited the funds in M0 money (reserves).
- Iron Bank issues Iron Bank M1 money to Chris.
- In the DRM ledger, each of these "hops" is done automatically.
If any one of these hops fail, the entire transfer fails.
Initiate and Commit
To get the most out of the following section, you should first read the Role and Role Binding API documentation.
There are situations where you want to interact with an external system to validate a transfer. For instance, a bank wants to screen a transaction for fraud before completion. DRM solves such use cases through our initiate-and-commit system. Readers familiar with two-phase commit protocols will find themselves comfortable with this concept.
We have two transaction types:
InitiateTransfer
- debits every hop in the transfer, ensuring no balances drop below zero.CommitTransfer
- performs the credit side of the operation.
The true power of this system comes when combined with the DRM RBAC system. In an example where a bank wishes to enforce fees on a transfer, it would grant the user Initiate
permissions on the user's account. The bank would hold Commit
permissions on the user's account. The bank could then observe InitiateTransfer
, and validate the transfer for correct fees.
If the fee is | Bank issues CommitTransfer with | Resulting action |
---|---|---|
incorrect | a new_state of rejected | the debit done in InitiateTransfer is rolled back. |
correct | a new_state of accepted | a credit is performed on each of the receiving accounts |
Model
The data model for a transfer on the DRM hierarchical ledger account is defined in transaction.proto
:
API Requests
Create a single transfer
- Rust
- TypeScript
- Dart
- CLI
Create a multi-transfer
- Rust
- TypeScript
- Dart
- CLI
Transfer with metadata
- Rust
- TypeScript
- Dart
- CLI
Initiate & Commit
- Rust
- TypeScript
- Dart
- CLI
List (Find)
Use filters to list all transfers that match a certain criteria.
- Rust
- TypeScript
- Dart
- CLI
Get
Get a specific transfer.
- Rust
- TypeScript
- Dart
- CLI
Observe
Observe transfers on an account. Transfer data is streamed in real-time.
- Rust
- TypeScript
- Dart
- CLI
To submit requests over HTTP/1 instead of HTTP/2 with the SDKs, use the http option.