Skip to content

Commit d52afcf

Browse files
authored
Merge pull request #30 from Blockchain-Data-Analytics/improve_docs
improve docs; +simulation spreadsheet
2 parents 9968355 + c15ae0e commit d52afcf

18 files changed

+95
-133
lines changed

doc/Flow.md

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,36 @@
11
# Flow of transactions
22

3-
A combination of off-chain and on-chain transactions define the interaction of the client with the system.
3+
A service instance is represented by a smart contract on a blockchain. The contract's state changes with transactions on it by the user and the service provider.
44

5-
* a fiat on-ramp sells service tokens in the sense of a gift card to the client who's on-chain account will be credited with the corresponding amount
6-
* alternative: accepting crypto currencies might trigger the same
7-
* the client exposes a fraction of her balance to the service
8-
* this is an on-chain transaction of transferring tokens from a client's account back to the service account
9-
* in return the client is credited with internal service tokens (GEEZ)
10-
* the client starts and uses services
11-
* which then debit their usage from the client's GEEZ account
5+
* at first, the contract is created by the service manager with references to the provider's and the user's addresses so to allow only interaction from these accounts
6+
* the user deposits a small amount to start the contract
7+
* both the user and the provider can intermittently withdraw funds from the contract
8+
* the user may deposit more funds to extend the duration of the contract
9+
* either the user or the provider call "stop" on the contract, or the contract runs out of funds
10+
* after this point, the contract cannot be started again, the balances don't change anymore
1211

13-
This approach has some
1412

15-
### CONS
16-
- it is a bit laborous for the client
17-
- fiat payment, then on-chain transfer of tokens
18-
- there are some parts which depend on "trust" like the account of GEEZ which is presumably held in an internal and opaque database
13+
## On-ramp, off-ramp
1914

20-
### PROS
21-
- only a fraction of the client's holding are at stake, the rest is kept in an on-chain account
22-
- a fiat on-ramp process allows more users to use the system
23-
- not everybody can, wants, or is allowed to use cryptocurrencies
24-
- low transaction fees
25-
- fiat on-ramp: \<5% charged to the service
26-
- on-chain transfer: $0.05 or lower charged to the client
15+
All services on this platform are payable in a token, named BCA1, that represents the value of one Euro per token.
16+
Such tokens can be purchased using fiat money in our on-ramp service. And, token holders can request a payout to a bank account by returning the tokens.
2717

28-
## Transactions
18+
### The user buys service tokens using fiat and gets credited
2919

30-
Let's have a closer look at the transactions involved.
31-
32-
### The client buys service tokens using fiat and gets credited
33-
34-
The client buys in a conventional fiat transaction some tokens. This is reflected by minting new tokens to the client's on-chain account.
20+
The user buys in a conventional fiat transaction some tokens. This is reflected by minting new tokens to the user's on-chain account.
3521

3622
![Fiat on-ramp](./img/tx0-1.png)
3723

3824

39-
### The client charges her account
40-
41-
Using an on-chain transaction, the client transfers a number of tokens to the _serviceAccount_.
42-
43-
This is reflected in crediting the client's off-chain account with "Geez" tokens of the same amount.
25+
### The user deposits tokens for service micro-payments
4426

45-
![Charge client account](./img/tx2.png)
27+
Using an on-chain transaction, the user transfers a number of tokens to a smart contract representing a service instance.
4628

29+
![User deposit](./img/tx2.png)
4730

48-
### Services debit the client's account for micropayments
4931

50-
In an off-chain setup, or on a private blockchain with minimal transaction fees, services can debit client accounts for their service usage.
32+
### Balances of both parties are managed in the smart contract
5133

52-
This is immediately reflected in an updated balance in the client's account.
34+
After the contract is started, the user's and the provider's balances are maintained. These balances determine how much each party can withdraw from the contract. While the user's balance diminishes with time, the provider's balance will increase.
5335

5436
![Service usage debit](./img/tx3.png)

doc/Services.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
# Service Management
22

3+
Contract [Solidity](../bca-token-solidity/contracts/BCA_Service.sol) code
4+
35
There are three parties involved:
4-
- the user which initiates the requests
5-
- the service manager which manages the user's account and communicates with both the user and the service providers
6+
- the service account that owns the contract
7+
- the user who requests and funds the service
68
- the service provider which provides services and manages them
9+
- represented by the service controller which reacts to events of the contract
710

811
![Use case services](./img/UC2.png)
912

1013

11-
## Starting a service
14+
## Setting up a new service instance
1215

1316
The user requests a new service with the service manager.
1417

15-
The service manager invokes the setup process with the service provider.
18+
The service manager invokes the setup process with the service provider and deploys a new smart contract for this service instance.
1619

17-
After the process ends successfully, the service providers hands over the credentials in a secure way to the user via the service manager.
20+
To progress in the setup, the user must first deposit enough funds in the contract.
1821

19-
At this time, the user can use the service.
22+
After the setup process ends successfully, the service provider hands over, in a secure way, the access credentials to the user via the service manager.
2023

2124
![Sequence diagram start service](./img/Seq-Service-Start.png)
2225

2326

2427
## Stopping a service
2528

26-
The user requests a service he has subscribed to be shutdown.
27-
28-
The service manager invokes the shutdown process with the service provider.
29+
The user requests a subscribed service to be shutdown with a call to the "stop" method of the contract. Or, the user's deposit on the contract is exhausted.
2930

30-
At the end of the process, the service provider acknowledges the sunsetting of the service and send this via the service manager to the user.
31+
The service controller reacts to the Stop event and invokes the shutdown process of the service.
3132

3233
![Sequence diagram stop service](./img/Seq-Service-Stop.png)
3334

3435

3536
## Billing of services
3637

37-
The service manager debits the user's account periodically for the services in use.
38+
The contract is effectively calculating the user's and the provider's balances on arrival of a transaction.
3839

39-
The time periods of a tick are per hour: from one up to 24 hours.
40+
Since the parameters of the contract are known, these balances can also be deterministically calculated off-chain.
4041

41-
A service is in use after it has been started. The usage ends with the stopping of the service.
42-
If the user's account runs out of credits, then the service is stopped immediately and the usage ends.
42+
This has the same effect as micro-payments. Users only pay for their usage and service providers earn a revenue stream. If the calculated balance is reasonably high, then a provider might withdraw their balance.
43+
44+
A service is in use after it has been started with a first deposit by the user. The usage ends with the stopping of the service, or if the user's balance runs out of funds.
4345

4446
At start of a service an initial setup fee can be charged. This fee also includes a potential tear down fee when the service is shut down; there is no extra fee due when the servicing ends.
4547

46-
At the end of the time period, the user's account is charged.
48+
### Contract simulation
4749

48-
### Process of billing
49-
![Charging for service usage](./img/Seq-Service-Billing.png)
50+
The [spreadsheet](./img/Tokenized_Service_Contract_Simulation.ods) contains simulations for a short lived and a long-running service contract and the calculation of the user's and the provider's balances.
5051

51-
### Details of the accounting class
52-
![ServerManager debits the user](./img/Iface-Billing.png)
52+
![long-running service contract simulation](./img/sim_contract.png)
53+
This shows the balances of the user and the provider over the lifespan of the service contract. The user regularly deposits coins to fund the service. Also, the provider withdraws funds as soon as they reach a certain amount.
5354

5455
## Registering a service controller
5556

@@ -60,4 +61,3 @@ The service controller runs on the service provider's infrastructure.
6061
Between the two there is a secure VPN connection installed such that either party is assured to only communicate with the other and nobody else is listening.
6162

6263
![Interface Service Controller](./img/Iface-Service-Controller.png)
63-

doc/Tokenization.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
## ERC20 Service Contract
55

6-
76
![Contract interactions](./img/UC1.png)
87

8+
Contract [Solidity](../bca-token-solidity/contracts/BCA_ERC20_nf.sol) code
99

1010
### public methods
1111
The ERC20 contract allows the following methods:
@@ -24,17 +24,10 @@ These methods can only be called from the _serviceAccount_
2424
### supply methods
2525

2626
- mint
27-
> only allowed from the _minter_
27+
> only allowed from the _minter_ account
2828
2929
- burn
30-
> only allowed from the _burner_
30+
> only allowed from the _burner_ account
3131
3232
> will burn tokens in the _serviceAccount_
3333
34-
35-
### transfer method
36-
37-
This method only allows to transfer tokens from a user's account to the _serviceAccount_
38-
39-
Users cannot transfer tokens to their addresses.
40-

doc/img/Iface-Billing.png

1.07 KB
Loading
602 Bytes
Loading

doc/img/Seq-Service-Billing.png

-18.5 KB
Binary file not shown.

doc/img/Seq-Service-Start.png

7.44 KB
Loading

doc/img/Seq-Service-Stop.png

-4.92 KB
Loading
1.93 MB
Binary file not shown.

doc/img/UC2.png

-744 Bytes
Loading

0 commit comments

Comments
 (0)