Skip to content

Commit bd2f9bc

Browse files
authored
Add aiken example (#91)
* Add aiken tooling and example * Generate blueprint from aiken, load blueprint in haskell * Add nix cache * Scaffolding * Deserialise; failing test * WIP registration * WIP build tx * Implement registration * Add query function for registry node * Use Query.registryNodes where possible * Move some testing functions to test-lib * WIP testlib * Update folder and module structure * Move some modules to programmable-tokens-test and -offchain * Move some functions to programmable-tokens-offchain * Separate blacklist logic from transfer logic * Move some queries to programmable-tokens-offchain * Move more queries over * Fix argument duplication in register tx * Move some code around * Updates * Fix tests * Move some tests over to programmable-token-tests * Clean up some testing code * Always-succeeds test * Address compiler warnings * Aiken policy registration test passing * Cleanup * Add transfer incl. redeemer * Two different validators for withdrawing and minting * Add CLI excetubale * Preview network deployment * Implement register command * Implement issue endpoint * Fix tests * Add a --dry-run flag * Add tx-vis script * Finishing touches * Update README * Fix some compiler warnings * Update generated files * Fix container * Fix CI command * accept flake config * Build cip-143-cli container
1 parent bd23788 commit bd2f9bc

File tree

124 files changed

+4857
-2052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+4857
-2052
lines changed

.github/workflows/ci-compiled-scripts.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ jobs:
2121
2222
- name: Install system dependencies
2323
uses: input-output-hk/actions/base@latest
24+
25+
- name: Install nix
26+
uses: cachix/install-nix-action@v27
27+
2428

2529
- uses: haskell-actions/setup@v2
2630
id: cabal-setup
@@ -39,13 +43,13 @@ jobs:
3943
- name: build & test
4044
run: |
4145
cabal update
42-
cabal build -j all --enable-tests
43-
cabal test all
46+
cabal build -j all
4447
- name: check compiled scripts are consistent
4548
# git diff --quiet implies --exit-code
4649
run: |
4750
cabal run export-smart-tokens ./generated/scripts/unapplied
4851
cabal run export-smart-tokens ./generated/scripts/preview 08a8d0bb8717839931b0a594f7c28b0a3b7c78f6e9172e977e250eab7637d879.0 08a8d0bb8717839931b0a594f7c28b0a3b7c78f6e9172e977e250eab7637d879.0 '"addr_test1qq986m3uel86pl674mkzneqtycyg7csrdgdxj6uf7v7kd857kquweuh5kmrj28zs8czrwkl692jm67vna2rf7xtafhpqk3hecm"'
4952
cabal run export-smart-tokens ./generated/scripts/mainnet b1977c1eb33590ca1311384ab68cd36209832213ad4483feb8a1b7cb64828946.0 b1977c1eb33590ca1311384ab68cd36209832213ad4483feb8a1b7cb64828946.0 '"addr_test1qq986m3uel86pl674mkzneqtycyg7csrdgdxj6uf7v7kd857kquweuh5kmrj28zs8czrwkl692jm67vna2rf7xtafhpqk3hecm"'
5053
cabal run write-openapi-schema -- generated/openapi/schema.json
54+
nix develop --accept-flake-config --command bash -c "aiken build src/examples/aiken/aiken --out ./src/examples/aiken/haskell/data/aiken-scripts.json"
5155
git diff --quiet

.github/workflows/ci-nix.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ jobs:
5050
# key: cabal-${{ hashFiles('cabal.project') }}
5151

5252
# We currently do not have a default target
53-
- name: nix build wst-poc client application
54-
run: nix build --accept-flake-config .#wst-poc-cli
53+
- name: nix build command-line apps
54+
run: |
55+
nix build --accept-flake-config .#cip-143-cli
56+
nix build --accept-flake-config .#regulated-stablecoin-cli
5557
- name: nix flake check
5658
run: nix flake --accept-flake-config check
59+
- name: Check aiken
60+
run: nix develop --accept-flake-config --command bash -c "cd src/examples/aiken/aiken && aiken build && aiken check"

.github/workflows/ci-oci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
tests:
2626
strategy:
2727
matrix:
28-
image: [wst]
28+
image: [wst, cip-143-cli]
2929
runs-on: ubuntu-latest
3030
steps:
3131

README.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1-
# CIP-0143 and programmable token POC
1+
# CIP-143 reference implementation and examples
22

3-
This is a proof-of-concept for _WST_, a programmable token with freeze and seize capabilities, based on [CIP-0143](https://github.com/colll78/CIPs/blob/patch-3/CIP-0143/README.md). The programmable logic of _WST_ checks whether the target address is blacklisted before allowing a transfer of the programmable token from one owner to another.
3+
This repository contains a reference implementation of [CIP-143](https://github.com/colll78/CIPs/blob/patch-3/CIP-0143/README.md).
4+
The CIP describes a registry of token standards around programmable assets, and some conventions for Cardano addresses that hold programmable assets.
5+
6+
## CLI
7+
8+
`cip-143-cli` is a tool for registering CIP-143 policies and for issuing and transfering tokens.
9+
10+
### CLI Commands
11+
12+
* `deploy` deploys a new instance of the CIP-143 registry
13+
* `policy` offers a number of commands for managing CIP-143 policies. All sub-commands of `policy` require a blueprint JSON file with the minting and transfer scripts.
14+
* `register` registers the stake scripts that are used by the policy
15+
* `issue` mints a number of programmable assets
16+
* `transfer` sends programmable assets to another account
17+
* `info` prints some information on the policies
18+
19+
### Blueprint format
20+
21+
The `policy` command expectes a blueprint JSON file.
22+
The blueprint should have two validators called `transfer.issue.withdraw` and `transfer.transfer.withdraw`.
23+
The validators will be called as reward withdrawal validators.
24+
25+
## Freeze-and-seize stablecoin
26+
27+
There is a proof-of-concept for _WST_ a programmable token with freeze and seize capabilities, based on [CIP-0143](https://github.com/colll78/CIPs/blob/patch-3/CIP-0143/README.md). The programmable logic of _WST_ checks whether the target address is blacklisted before allowing a transfer of the programmable token from one owner to another.
428

529
![Screenshot of the UI showing the minting authority.](image-1.png)
630

@@ -18,18 +42,19 @@ See [doc/architecture.md](doc/architecture.md)
1842

1943
This repository contains
2044
* Prototype implementation of CIP-0143 in Plutarch (see `src/programmable-tokens`)
45+
* `cip-143-cli`, a command-line tool for deploying and managing CIP-143 compliant policies
2146
* Prototype implementation of _WST_, a programmable token with freeze-and-seize capbilities, in Plutarch (see `src/regulated-stablecoin`)
22-
* Transaction building code for initial deployment, minting programmable tokens, transferring programmable tokens, adding addresses to the blacklist (ie. freezing), and seizing funds from blacklisted addresses. Based on sc-tools and cardano-api.
23-
* Emulator tests for the nominal cases (happy path) based on the actual ledger implementation and mainnet protocol parameters.
24-
* A user interface that implements the use cases using browser-based wallets. Based on next.js and lucid.
25-
* An OCI container image with the on-chain code, the off-chain code and the UI
47+
* Transaction building code for initial deployment, minting programmable tokens, transferring programmable tokens, adding addresses to the blacklist (ie. freezing), and seizing funds from blacklisted addresses. Based on sc-tools and cardano-api.
48+
* Emulator tests for the nominal cases (happy path) based on the actual ledger implementation and mainnet protocol parameters.
49+
* A user interface that implements the use cases using browser-based wallets. Based on next.js and lucid.
50+
* An OCI container image with the on-chain code, the off-chain code and the UI
51+
52+
### Using the Freeze-and-seize stablecoin example
2653

2754
With the container image it is possible to run the complete system locally with just a single command.
2855
There is no need to install the build toolchain or to operate a cardano node or related infrastructure.
2956
The image can even be used to interact with existing deployments of the POC.
3057

31-
# Usage
32-
3358
The easiest way to get started is by running the [wst](https://github.com/input-output-hk/wsc-poc/pkgs/container/wst) image locally:
3459

3560
```bash

cabal.project

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ allow-older:
3131
-- TODO: Delete when plutarch is moving to 1.37
3232
plutarch:plutus-core
3333

34-
3534
with-compiler: ghc-9.6.6
3635

3736
packages:
38-
src/programmable-tokens
39-
src/regulated-stablecoin
40-
37+
src/programmable-tokens-onchain
38+
src/programmable-tokens-offchain
39+
src/programmable-tokens-test
40+
src/examples/regulated-stablecoin
41+
src/examples/aiken/haskell
4142

4243
source-repository-package
4344
type: git
@@ -53,6 +54,7 @@ source-repository-package
5354
src/base
5455
src/node-client
5556
src/blockfrost
57+
src/tx-mod
5658

5759
source-repository-package
5860
type: git

deploy-registry.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
export CIP_143_BLOCKFROST_TOKEN=preview1F0TvMF5VAk70b5YPiR20njoEG9ByGjf
4+
5+
cabal run cip-143-cli -- deploy --signing-key-file=preview-network/operator.sk \
6+
preview-network/preview_script_root.json

deployment-root.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)