Skip to content

Commit

Permalink
docs: building basic docs
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Nov 29, 2023
1 parent 52f1f12 commit dd0a113
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 30 deletions.
65 changes: 38 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
# aiken-content-ownership

This is the implementation of on-chain content ownership with below features:

1. User can create content and leverage Cardano blockchain to record ownership
2. The content owner can update the content anytime
3. The content owner can transfer content ownership to others
4. Forward compatible: Incentive mechanism expansion
5. Scalable: Up to 10,000 users, each with 10,000 piece of content
6. User can use any native asset on Cardano to represent ownership identity

## Building
# Script Actions

```sh
aiken build
```
## Scripts

## Testing
The specification of all scripts involved could be found at [scripts_specs.md](./specs/scripts_specs.md). Scripts are labelled with number 1 - 6. And we would use the label for referring to validation logic needed on below.

You can write tests in any module using the `test` keyword. For example:
## Setup

```gleam
test foo() {
1 + 1 == 2
}
```
The are 4 steps of setting up the applications:

To run all tests, simply do:
1. Minting `oracle_nft`, one time minting policy with empty token name with quantity of 1.
- Validation: 1.1
2. Sending the the `oracle_nft` to `oracle_validator` with initialized inline datum of specifying all compile scripts, addresses with owner keys. Setting both registry counts to `0`.
- Validation: N/A
3. Creating `content_registry` by minting `content_registry_ref_token` to `content_registry` address.
- Validation: 2.1, 3.1
4. Creating `ownership_registry` by minting `ownership_registry_ref_token` to `ownership_registry` address.
- Validation: 2.2, 4.1

```sh
aiken check
```
Step 3 and 4 would be repeated anytime, considering:

To run only tests matching the string `foo`, do:
- Operating concurrency (1 UTxO = 1 concurrency)
- Registry size (desired size to be tested)

```sh
aiken check -m foo
```
## User Actions

## Documentation
1. Create Content
- Validation: 4.1, 6.1
2. Update Content
- Validation: 4.2
3. Transfer Ownership
- Validation: 6.2

If you're writing a library, you might want to generate an HTML documentation for it.
## Admin Actions

Use:
1. Rotate keys
- Validation: 2.3
2. Stop Oracle
- Validation: 1.2, 2.4
3. Stop Content Registry
- Validation: 3.2, 4.3
4. Stop Ownership Registry
- Validation: 5.2, 6.3

```sh
aiken docs
```
# Testing

## Resources
There is unit tests in this implementation. To run all tests, simply do:

Find more on the [Aiken's user manual](https://aiken-lang.org).
```sh
aiken check
```
6 changes: 3 additions & 3 deletions lib/aiken-content-ownership/validators/content_registry.ak
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub fn content_registry_logic(
ref_token.2nd,
),
)
let is_regisry_updated =
let is_registry_updated =
check_is_content_registry_updated(
content_input.output.datum,
content_output.datum,
Expand All @@ -191,11 +191,11 @@ pub fn content_registry_logic(
raw_ownership_ref_datum
expect Some(original_owner) =
dict.get(ownership_ref_datum.registry, content_number)
let is_update_authoized =
let is_update_authorized =
inputs_token_quantity(inputs, original_owner) > 0
let is_registry_value_clean =
list.length(flatten(content_output.value)) == 2
is_regisry_updated && is_update_authoized && is_registry_value_clean
is_registry_updated && is_update_authorized && is_registry_value_clean
}
StopContentRegistry ->
when
Expand Down
Empty file added specs/admin_actions.md
Empty file.
61 changes: 61 additions & 0 deletions specs/scripts_specs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Specification of Smart Contracts

1. One Time Minting Policy

- Serve as reference token living on oracle validator
- Param: Input UTxO
- Validation rules:
1. Minting rule: Param input is spent
2. Burning rule: Only negative amount exists regarding this policy

2. Oracle Validator

- Locking the oracle token with information for the Dapp
- Validation rules:
1. Create new content registry: The content registry reference token is minted (with correct name)
2. Create new ownership registry: The ownership registry reference token is minted (with correct name)
3. Rotate key: Transaction is signed by both operating key and stop key
- Redeemer info: new operation key and key stop key
4. Stop app: Oracle token is burned with signature from stop key

3. Content Registry Reference Token

- The minting policy of the reference token locked in content registry validator
- Param: oracle token policy
- Validation rules:
1. Minting rule: oracle_datum_updated && registry_initial_datum_correct && oracle_output_value_clean && registry_output_value_clean
2. Burning rule: Only negative amount exists regarding this policy

4. Content Registry Validator

- Param: oracle token policy
- Validation rules:
1. Create content
- Redeemer info: `content_hash` and `owner` token
- ref_tokens_equal && current_count_equal && content_new_datum_correct && ownership_new_datum_correct && content_registry_value_clean && ownership_registry_value_clean
2. Update content
- Redeemer: `new_content_hash` and `content_number` in the registry
- is_registry_updated && is_update_authorized && is_registry_value_clean
3. Stop content registry
- Content registry reference is burn
- Signed by stop key

5. Ownership Registry Reference Token

- The minting policy of the reference token locked in ownership registry validator
- Param: oracle token policy
- Validation rules:
1. Minting rule: oracle_datum_updated && registry_initial_datum_correct && oracle_output_value_clean && registry_output_value_clean
2. Burning rule: Only negative amount exists regarding this policy

6. Ownership Registry Validator

- Param: oracle token policy
- Validation rules:
1. Create ownership record: Content ownership input is also validating with create content redeemer
2. Transfer ownership
- Redeemer: `new_owner_token` and `content_number` in the registry
- is_original_owner_authorized && is_registry_updated && is_registry_value_clean
3. Stop ownership registry
- Ownership registry reference is burn
- Signed by stop key
Empty file added specs/setup.md
Empty file.
Empty file added specs/user_actions.md
Empty file.

0 comments on commit dd0a113

Please sign in to comment.