Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low Code Carbon Credit Implementation #22

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ yarn-error.log*
target
dist
gallery/public
.eslintcache
.eslintcache

*.tsbuildinfo
2 changes: 1 addition & 1 deletion deps/concordium-rust-sdk
Submodule concordium-rust-sdk updated 79 files
+2 −2 .github/workflows/build-and-test.yaml
+0 −41 CHANGELOG.md
+11 −12 Cargo.toml
+9 −9 README.md
+1 −1 concordium-base
+105 −68 examples/block-stats.rs
+1 −1 examples/create-initial-accounts.rs
+54 −20 examples/find-account.rs
+126 −0 examples/generator.rs
+2 −3 examples/init-update-contract.rs
+5 −2 examples/list-number-account-transactions.rs
+33 −79 examples/protocol-updates.rs
+1 −1 examples/v2_banpeers.rs
+6 −6 examples/v2_contract_deploy_init_update.rs
+2 −2 examples/v2_create_initial_accounts.rs
+1 −1 examples/v2_get_account_info.rs
+1 −1 examples/v2_get_account_list.rs
+3 −2 examples/v2_get_account_non_finalized_transactions.rs
+1 −1 examples/v2_get_ancestors.rs
+1 −1 examples/v2_get_anonymity_revokers.rs
+1 −1 examples/v2_get_baker_list.rs
+1 −1 examples/v2_get_block_chain_parameters.rs
+1 −1 examples/v2_get_block_finalization_summary.rs
+11 −6 examples/v2_get_block_info.rs
+1 −1 examples/v2_get_block_item_status.rs
+1 −1 examples/v2_get_block_items.rs
+1 −1 examples/v2_get_block_special_events.rs
+1 −1 examples/v2_get_blocks_at_height.rs
+1 −1 examples/v2_get_branches.rs
+1 −1 examples/v2_get_consensus_info.rs
+1 −1 examples/v2_get_cryptographic_parameters.rs
+1 −1 examples/v2_get_election_info.rs
+1 −1 examples/v2_get_finalized_blocks.rs
+1 −1 examples/v2_get_identity_providers.rs
+1 −1 examples/v2_get_instance_info.rs
+1 −1 examples/v2_get_instance_list.rs
+1 −1 examples/v2_get_instance_state.rs
+1 −1 examples/v2_get_instances_stats.rs
+1 −1 examples/v2_get_module_list.rs
+1 −1 examples/v2_get_module_source.rs
+1 −1 examples/v2_get_next_account_sequence_number.rs
+1 −1 examples/v2_get_next_update_sequence_numbers.rs
+1 −1 examples/v2_get_node_info.rs
+1 −1 examples/v2_get_passive_delegation_info.rs
+1 −1 examples/v2_get_passive_delegators.rs
+1 −1 examples/v2_get_passive_delegators_reward_period.rs
+1 −1 examples/v2_get_peers_info.rs
+1 −1 examples/v2_get_pool_delegators.rs
+1 −1 examples/v2_get_pool_delegators_reward_period.rs
+1 −1 examples/v2_get_pool_info.rs
+1 −1 examples/v2_get_tokenomics_info.rs
+1 −1 examples/v2_instance_state_lookup.rs
+1 −1 examples/v2_invoke_instance.rs
+1 −1 examples/v2_list_cis2_contracts.rs
+1 −1 examples/v2_list_instances.rs
+1 −1 examples/v2_networkdumps.rs
+1 −1 examples/v2_peer_connect.rs
+1 −1 examples/v2_register_data.rs
+1 −1 examples/v2_send_encrypted_transfer.rs
+1 −1 examples/v2_send_transfer.rs
+1 −1 examples/v2_shutdown.rs
+1 −1 examples/v2_traverse_all_transactions.rs
+1 −2 examples/v2_update_exchange_rate.rs
+0 −14 src/cis0.rs
+238 −62 src/cis2/mod.rs
+0 −281 src/cis4.rs
+0 −249 src/contract_client.rs
+2 −7 src/internal.rs
+12 −11 src/lib.rs
+0 −1 src/postgres.rs
+15 −76 src/types/mod.rs
+18 −80 src/types/queries.rs
+1 −11 src/types/smart_contracts.rs
+0 −47 src/v1/generated/concordium.rs
+84 −290 src/v2/conversions.rs
+30 −687 src/v2/generated/concordium.v2.rs
+21 −295 src/v2/mod.rs
+1 −1 src/v2/proto_schema_version.rs
+0 −162 src/web3id.rs
47 changes: 47 additions & 0 deletions low-code-carbon-credits-marketplace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Concordium Carbon Credits Sample Implementation

## Run

1. Prerequisites
1. Install [Yarn](https://yarnpkg.com/)
2. Install [Docker](https://docs.docker.com/get-docker/)
3. Install [Docker Compose](https://docs.docker.com/compose/install/)
4. Install [Node.js](https://nodejs.org/en/download/)
5. Install [Concordium Client](https://developer.concordium.software/#/concordium-client)
6. Install [cargo-concordium](https://developer.concordium.software/en/mainnet/smart-contracts/guides/setup-tools.html)

2. Build

```bash
yarn && yarn build
```

3. Deploy Smart Contracts

```bash
yarn deploy:contracts wallet-account
```

**wallet-account** is the name of the account setup in the Concordium Client.

4. Setup


5. Run
1. Run [Events Listener Backend](./indexer/server/src/listener.ts)
abizjak marked this conversation as resolved.
Show resolved Hide resolved

```bash
yarn debug:listener
```

2. Run [Web Backend](./indexer/server/src/web.ts)

```bash
yarn debug:web
```

3. Run [Web Frontend](./market-ui/README.md)

```bash
yarn start:ui
```
1 change: 1 addition & 0 deletions low-code-carbon-credits-marketplace/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
215 changes: 215 additions & 0 deletions low-code-carbon-credits-marketplace/contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions low-code-carbon-credits-marketplace/contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "carbon-credit-module"
version = "0.1.0"
authors = ["Stactrace Solutions <[email protected]>"]
edition = "2021"
license = "MPL-2.0"
rust-version = "1.65.0"

[features]
default = ["std", "wee_alloc"]
std = ["concordium-std/std", "concordium-cis2/std"]
wee_alloc = ["concordium-std/wee_alloc"]

[dependencies]
concordium-std = { version="8.0.0", default-features = false }
concordium-cis2 = { version="5.0.0", default-features = false }
hex = "0.4.3"

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
codegen-units = 1
opt-level = "s"
42 changes: 42 additions & 0 deletions low-code-carbon-credits-marketplace/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Carbon Credits Market Reference Implementation

## User Roles

* Admin : Represents the governance of the system. The role is responsible for setting up the system and adding verifiers to the system.
* Project Owner : Represents the owner of the Carbon Credit Project. Can mint / retract a carbon credit project or can fractionalize a carbon credit project into carbon credit tokens.
* Verifier : Responsible for verification of a carbon credit project. Only Verified & Mature projects can be retired.
* Buyer : Any Account which wants to buy a Carbon Credit / Carbon Credit Token from the marketplace contract.

## Contracts

### [`project_token`](./src/project_token/mod.rs)

CIS2 Token contract implementation for Carbon Credits Projects. In Addition to CIS2 spec functionality it has the following functionality

* [`is_verified`](./src/project_token/is_verified.rs) : Can be called to check if the token is verified or not.
* [`is_verifier`](./src/carbon_credits/is_verifier.rs) : Can be called to check if an account address is a verifier.
* [`verifier_operations`](./src/project_token/verifier_operations.rs)
* `add_verifier` : Used by the contract owner to add a carbon credit verifier
* `remove_verifier`: Used by contract owner to remove a verifier.
* `verify`: Used by a verifier to mark a project token as verified.
* [`retire`](./src/project_token/retire.rs) : Can be used by the project owner to retire a carbon credit project
* [`retract`](./src/project_token/retract.rs) : Non Mature projects can be retracted by the verifier Or the project owner.

### [`carbon_credits`](./src/carbon_credits/mod.rs)

CIS2 Token contract implementation for Carbon Credits. In Addition to CIS2 specs functionality provides the following functionality.

Carbon Credit Projects can be sent to this contract fo fractionalization into carbon credits. The sent project is reffered to as `collateral` in the contract's code.

* [`is_verified`](./src/carbon_credits/is_verified.rs) : Can be used to check if the carbon credit is verified or not
* [`is_verifier`](./src/carbon_credits/is_verifier.rs) : Can be called to check if an account address if a verifier.
* [`retire`](./src/project_token/retire.rs) : Can be used by the project owner to retire a carbon credit
* [`retract`](./src/project_token/retract.rs) : Non Mature tokens can be retracted by the verifier Or the project owner.

### [`carbon_credits_market`](./src/carbon_credit_market/mod.rs)

Reference marketplace implementation for Carbon Projects & Carbon Credits.
Carbon Credit Project Or Carbon Credits can be sent to this contract to list them for a price which any one can pay and claim ownership of a carbon project / credit. The contract has the following functionality.

* [`list`](./src/carbon_credit_market/list.rs) : Can be used to list a carbon project / credit on the marketplace for a price.
* [`transfer`](./src/carbon_credit_market/transfer.rs) : Can be called with a specified amount to transfer a carbon project / credit to the payer.
11 changes: 11 additions & 0 deletions low-code-carbon-credits-marketplace/contracts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "contracts",
"version": "1.0.0",
"author": "[email protected]",
"license": "MIT",
"private": true,
"scripts": {
"build": "cargo concordium build --out=module.wasm --schema-base64-out=schema_base64.txt",
"deploy": "concordium-client --grpc-ip node.testnet.concordium.com module deploy ./module.wasm --no-confirm --sender"
}
}
Loading