-
Notifications
You must be signed in to change notification settings - Fork 0
Brokerage Engine
The blockchain for the Brokerage Engine of AEGIS was developed using Hyperledger Fabric v1.0 and Hyperledger Composer. The network consists of an Orderer, a CA authority, a peer and a CouchDB database for queries. Additional organizations, peers and orderers will be added in future versions.
Detailed installation steps can be found at the AEGIS Network Repository.
Along with the network, a REST API server is installed, allowing to interact with it. The following endpoints are available:
-
Get a list of all users registered with the brokerage engine:
GET /api/User
-
Add a user to the brokerage engine
POST /api/User
Example Body
{ "$class": "eu.aegis.User", "uid": "[email protected]", "balance": "0.0", "externalAssets": [ {} ] }
-
Get user's details:
GET /api/User/{uid}
-
Load currency to the balance of a user:
POST /api/LoadBalance
Example Body
{ "$class": "eu.aegis.LoadBalance", "amount": 0, "user": "eu.aegis.User#[email protected]", "transactionId": "string", "timestamp": "2018-03-21T10:10:29.384Z" }
-
Get a list of all AEGIS assets:
GET /api/AEGISAsset
-
Add an asset to the brokerage engine:
POST /api/AEGISAsset
Example Body
{ "$class": "eu.aegis.AEGISAsset", "aid": "1234", "type": "Dataset", "cost": "0.0", "status": "Free", "exclusivity": "None", "contractText": "Lorem Ipsum...", "owner": "eu.aegis.User#[email protected]" }
-
Get asset’s details:
GET /api/AEGISAsset /{aid}
-
Buy an asset:
POST /api/BuyAsset
Example Body
{ "$class": "eu.aegis.BuyAsset", "buyer": "eu.aegis.User#[email protected]", "relatedAsset": "eu.aegis.AEGISAsset#1234", "transactionId": "string", "timestamp": "2018-03-21T10:10:29.343Z" }
-
Change the cost of an AEGIS asset:
POST /api/ChangeAssetCost
Example Body
{ "$class": "eu.aegis.ChangeAssetCost", "newCost": 0, "relatedAsset": "eu.aegis.AEGISAsset#1234", "transactionId": "string", "timestamp": "2018-03-21T10:10:29.343Z" }
-
Change the status of an AEGIS asset (i.e. free, paid etc):
POST /api/ChangeAssetStatus
Example Body
{ "$class": "eu.aegis.ChangeAssetStatus", "newStatus": "Free", "relatedAsset": "eu.aegis.AEGISAsset#1234", "transactionId": "string", "timestamp": "2018-03-21T10:10:29.356Z" }
-
Change the exclusivity of an AEGIS asset (i.e. none, lifetime etc):
POST /api/ChangeExclusivity
Example Body
{ "$class": "eu.aegis.ChangeExclusivity", "newPeriod": "None", "relatedAsset": "eu.aegis.AEGISAsset#1234", "transactionId": "string", "timestamp": "2018-03-21T10:10:29.368Z" }
- Create new user - Creates a user with user id (uid in the code snippet below) [email protected] , having an initial balance of 1000 tokens: curl -XPOST https://localhost:3000/api/User -H 'Accept: application/json' -d '{ "$class": "eu.aegis.User", "uid": "[email protected]", "balance": "1000.0" }'
• Get all users curl -XGET https://localhost:3000/api/User
• Get specific userʼs details - To get a specific userʼs information, add the uid at the end of the url. i.e.: curl -XGET https://localhost:3000/api/User/[email protected]
• Load tokens to a userʼs account - To load 200 tokens to (user with uid) [email protected] : curl -XGET https://localhost:3000/api/LoadBalance -H 'Accept: application/json' -d '{ "user": "resource:eu.aegis.User#[email protected]", "amount": 200 }'
Asset Management • Create a new asset To create an asset, you need to provide an asset id (aid below), its type (can be any of: Dataset , Microservice , Algorithm , Analysis , Visualization , Other ), the cost of the asset, its status (can be Free , Paid , Subscription or Private - i.e. not for sale) and its owner (the uid of the user that owns the dataset). curl -XPOST https://localhost:3000/api/AEGISAsset -H 'Accept: application/json' -d '{ "$class": "eu.aegis.AEGISAsset", "aid": "1", "assetType": "Dataset", "cost": 100, "status": "Paid", "owner": "[email protected]" }'
• Get all assets curl -XGET https://localhost:3000/api/AEGISAsset
• Get details on a specific asset - As with user, we use the aid as a parameter curl -XGET https://localhost:3000/api/AEGISAsset/1
• Change the status of an asset - To change the status of asset with aid=1 to Private , use: curl -XPOST https://localhost:3000/api/ChangeAssetStatus -H 'Accept: application/json' -d '{ "relatedAsset": "eu.aegis.AEGISAsset#1", "newStatus": "Private" }'
• Change the cost of an asset - To change the status of asset with aid=1 to Private , use: curl -XPOST https://localhost:3000/api/ChangeAssetCost -H 'Accept: application/json' d '{"relatedAsset": "eu.aegis.AEGISAsset#1", "newCost": "200" }'
Building Contracts • Create a new (draft) contract - To create a contract, you need to provide a transaction id (tid), the desired exclusivity (can be None , Subscription or Lifetime ), the amount (to be) paid, the status of the contract (always use Draft at this stage), a text containing the terms of the contract (optional), the buyer and the seller (using their uid s) and the asset to be sold (use its aid ). curl -XPOST https://localhost:3000/api/Contract -H 'Accept: application/json' -d '{ "$class": "eu.aegis.Contract", "tid": "123", "exclusivity": "None", "amountPaid": "100.0", "status": "Draft", "text": "string", "seller": "[email protected]", "buyer": "[email protected]", "relatedAsset": "eu.aegis.AEGISAsset#1" }'
• Get all contracts curl -XGET https://localhost:3000/api/Contract
• Get all contracts involving assets bought/sold by someone - To get all contracts with a specific buyer/seller we need to filter the contracts. This is done by appending a (url encoded) filter in the url. For example, to get all contracts involving [email protected] as a buyer, the filter should be: {"where": {"buyer": {"eq":"resource:eu.aegis.User#[email protected]"}}} As a seller: {"where": {"seller": {"eq":"resource:eu.aegis.User#[email protected]"}}} curl -XGET https://localhost:3000/api/Contract?filter={...} The url encoded example of contracts with assets bought by [email protected] is curl -XGET https://localhost:3000/api/Contract?filter=%7B%22where%22%3A%20%7B%22buyer% 22%3A%20%7B%22eq%22%3A%22resource%3Aeu.aegis.User%23john.doe%40example.com%22%7D%7D%7D
• Validate a contract - To validate (switch it from Draft it Active): curl -XPOST https://localhost:3000/api/ValidateContract -H 'Accept: application/json' -d '{ "contract": "eu.aegis.Contract#123" }' where 123 is the tid (as set in the draft contract creation).