Skip to content

Commit

Permalink
add contracts docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mgpai22 committed Jan 26, 2024
1 parent dac2370 commit 3c0b603
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
# winter-protocol

Write validators in the `validators` folder, and supporting functions in the `lib` folder using `.ak` as a file extension.
These contracts allow data to be securly and immutably saved and saved.

For example, as `validators/always_true.ak`
## Main requirements

```gleam
validator {
fn spend(_datum: Data, _redeemer: Data, _context: Data) -> Bool {
True
}
}
```
These are the main requirements the contracts need to fulfil:

- Allow minting and burning of singleton
- Preserve datum data during recreation
- Allow authorized addresses to interact with contract
- Allow destruction of contract

## Validators

### singleton

This validator ensures onlt one unique singleton can be minted.
It also allows for burn of respective singleton.

## object_event

This validator allows for two things:

- Recreation of utxo where datum is preserved and singleton is transferred
- Destruction of utxo where lovelace is extracted and singleton is burned

### Recreation

- lovelace of new utxo is greater than or equal to current utxo
- singleton is transferred
- datum is preserved
- creation info is the txId of the original tx. Only the first utxo is empty, the rest must
always point to the original tx.
- At least one signer in datum must be facilitating the transaction
- winter fee must be paid

### Spending

- singleton must be burned
- winter fee must be paid
- At least one signer in datum must be facilitating the transaction

## Building

Expand All @@ -20,14 +49,6 @@ aiken build

## Testing

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

```gleam
test foo() {
1 + 1 == 2
}
```

To run all tests, simply do:

```sh
Expand All @@ -39,17 +60,3 @@ To run only tests matching the string `foo`, do:
```sh
aiken check -m foo
```

## Documentation

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

Use:

```sh
aiken docs
```

## Resources

Find more on the [Aiken's user manual](https://aiken-lang.org).

0 comments on commit 3c0b603

Please sign in to comment.