Sequence
Ledger Infrastructure for Modern Applications
Sequence is a system of record for managing balances. It lets software teams focus on shipping and scaling their product instead of building and maintaining ledger infrastructure.
Sequence is a system of record for managing balances. It lets software teams focus on shipping and scaling their product instead of building and maintaining ledger infrastructure.
Assets in accounts...
Balances in Sequence are represented by token-like objects called assets. Assets are created, transferred, and retired. To ensure atomicity, a single transaction can include multiple actions involving any number of assets and accounts.
...Controlled by keys in enclaves
Cryptographic keys, which create and control assets and accounts, are managed in secure enclaves. Key access can be distributed across users, services, and organizations so multiple entities can transact on the same ledger with “least authority.”
Transactions in the ledger are authenticated by cryptographic keys. To create a key, provide an alias (a unique identifier).
1Key key = new Key.Builder()
2 .setAlias("my_key")
3 .create(ledger);
Accounts represent entities in the ledger and can hold balances of many assets. To create an account, provide an alias (a unique identifier) and one or more keys. Here we create an account for Alice.
1Account alice = new Account.Builder()
2 .setAlias("alice")
3 .addKey(key)
4 .create(ledger);
Assets represent different types of balances in the ledger. To create an asset, provide an alias (a unique identifier) and one or more keys. Here we create a USD asset.
1Asset usd = new Asset.Builder()
2 .setAlias("usd")
3 .addKey(key)
4 .create(ledger);
Transactions are atomic ledger updates that issue, transfer, and/or retire assets in the ledger. A transaction is comprised of one or more actions. Here is a transfer of USD from Alice to Bob.
1Transaction tx = new Transaction.Builder()
2 .addAction(new Transaction.Builder.Action.Transfer()
3 .setAssetAlias("usd")
4 .setAmount(10)
5 .setSourceAccountAlias("alice")
6 .setDestinationAccountAlias("bob")
7 ).transact(ledger);
Data structures in Sequence are represented as key-value JSON objects. To retrieve data, you perform a query with optional parameters. By default, each query returns a time-ordered list of objects beginning with the most recent. Here’s a query for the amount of USD in Alice's account.
1Balance.ItemIterable balances = new Balance.QueryBuilder()
2 .setFilter("asset_alias=$1 AND account_alias=$2")
3 .addFilterParameter("usd")
4 .addFilterParameter("alice")
5 .addSumByField("asset_alias")
6 .getIterable(ledger);
7 for (Balance balance : balances) {
8 ...
9 }