{"id":19358590,"url":"https://github.com/paritytech/co2-passport","last_synced_at":"2025-02-24T11:44:50.892Z","repository":{"id":181152201,"uuid":"623527027","full_name":"paritytech/co2-passport","owner":"paritytech","description":"Smart contracts for tracking carbon emissions in the steel industry. Prototype only, not production ready, not audited yet. ","archived":false,"fork":false,"pushed_at":"2023-09-27T23:28:03.000Z","size":589,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-06T18:36:55.468Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paritytech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-04T14:46:55.000Z","updated_at":"2023-12-26T22:27:25.000Z","dependencies_parsed_at":"2025-01-06T18:36:38.254Z","dependency_job_id":"f80eca54-b6a2-4369-b864-6ad7cde04c09","html_url":"https://github.com/paritytech/co2-passport","commit_stats":null,"previous_names":["paritytech/co2-passport"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fco2-passport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fco2-passport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fco2-passport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fco2-passport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paritytech","download_url":"https://codeload.github.com/paritytech/co2-passport/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240474162,"owners_count":19807280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T07:12:23.824Z","updated_at":"2025-02-24T11:44:50.870Z","avatar_url":"https://github.com/paritytech.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Non-Fungible Assets For Tracking CO2 Emissions\n\nThis smart contract is for tracking carbon emissions of steel. It is written in [ink!](https://github.com/paritytech/ink), a Rust based smart contract language for Substrate based blockchains.\n\n-   [Non-Fungible Assets with CO2 Emissions tracking](#non-fungible-assets-with-co2-emissions-tracking)\n    -   [Contract Overview](#contract-overview)\n    -   [Local development setup](#local-development-setup)\n        -   [Rust and Cargo](#rust-and-cargo)\n            -   [Cargo clippy linter](#cargo-clippy-linter)\n        -   [ink! smart contract tools](#ink-smart-contract-tools)\n        -   [pre-commit](#pre-commit)\n            -   [Install the git hook script](#install-the-git-hook-script)\n    -   [Local Deployment](#local-deployment)\n        -   [Contracts Node](#contracts-node)\n        -   [Smart Contract](#smart-contract)\n        -   [Smart Contracts UI](#smart-contracts-ui)\n    -   [Live Deployment](#live-deployment)\n        -   [Deploying on Contracts on Rococo](#deploying-on-contracts-on-rococo)\n    -   [Development](#development)\n        -   [Format code](#format-code)\n        -   [Run clippy linter](#run-clippy-linter)\n        -   [Check that smart contracts build to WASM](#check-that-smart-contracts-build-to-wasm)\n        -   [Testing](#testing)\n        -   [Build smart contracts](#build-smart-contracts)\n        -   [Run pre-commit](#run-pre-commit)\n    -   [CI Jobs](#ci-jobs)\n        -   [GitHub runners](#github-runners)\n        -   [Jobs](#jobs)\n    -   [Integration Tests](#integration-tests)\n        -   [Running Integration Tests](#running-integration-tests)\n\n## Contract Overview\n\nThis contract supports the following operations:\n\n-   Updating contract\n-   Blasting an Asset - creating a new Asset with the CO2 Emissions required\n-   Adding additional CO2 Emissions to an Asset\n-   Transferring an Asset to a different account. Additional C02 Emissions always added\n-   Pausing an Asset to prevent transferring or adding new CO2 Emissions. This is a prerequisite to splitting an Asset\n-   Splitting an Asset into child Assets. The common reasons is due to actions like steel cutting\n-   Querying details about an Asset\n-   Querying the full parent tree of a child Asset. This allows for calculating the total CO2 Emissions\n\n## Local development setup\n\n### Rust and Cargo\n\nFollow the [instruction](https://doc.rust-lang.org/cargo/getting-started/installation.html) to install Rust and Cargo.\n\n#### Cargo clippy linter\n\nFollow the [instruction](https://github.com/rust-lang/rust-clippy#usage) to install `clippy`.\n\n### ink! smart contract tools\n\nFollow the [instruction](https://use.ink/getting-started/setup) to install `ink!` smart contract tools.\n\n### pre-commit\n\nFollow the [instruction](https://pre-commit.com/#installation) to install `pre-commit` tool.\n\n#### Install the git hook script\n\n```sh\npre-commit install\n```\n\n## Local Deployment\n\n### Contracts Node\n\nIn a separated terminal start the Contracts Node:\n\n```sh\nsubstrate-contracts-node\n```\n\n### Smart Contract\n\nBuild Smart Contract:\n\n```sh\ncargo contract build --release\n```\n\n### Smart Contracts UI\n\n1. Go to [Contracts UI](https://contracts-ui.substrate.io/).\n1. Select `Upload a new contract`.\n1. In `Upload and Instantiate` window:\n    - Set contract name like `InfinityAsset`.\n    - Upload contract details -\u003e select `target/ink/asset_co2_emissions.contract` from the Smart Contract repository.\n    - Press `Next` button.\n    - Press `Next` button.\n    - Press `Upload and Instantiate` button.\n1. Interact with the Smart Contract.\n\n## Live Deployment\n\nThere are several places where an ink! contract can be deployed! The [ink! documentation](https://use.ink/#where-can-i-deploy-ink-contracts) has an up-to-date list of where to deploy.\n\n### Deploying on Contracts on Rococo\n\nThis example will be using [Contracts on Rococo](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-contracts-rpc.polkadot.io#/explorer) to deploy a contract.\n\n1. Get testnet tokens using [this faucet](https://use.ink/faucet/).\n2. Build the contract.\n\n```sh\ncargo contract build --release\n```\n\n3. Navigate to the Contracts page at [contracts-ui.substrate.io](https://contracts-ui.substrate.io/).\n4. Ensure \"Contracts (Rococo)\" is selected.\n   ![](images/contracts-home-page.png)\n5. Select `Upload a new contract`.\n   ![](images/contracts-page.png)\n6. Upload the built contract found at `./target/ink/asset_co2_emissions.contract`. This file contains the contract Wasm bytecode and the metadata.\n   ![](images/contracs-deploy.png)\n7. Click `Next`, modify the limits as desired. The default values are generally sufficient.\n   ![](images/contracts-upload.png)\n8. Click `Next` and finally `Upload and instantiate`.\n9. The contract can now be used.\n\nThe documentation found [here](https://use.ink/testnet) provides more details and also instructions on how deploy contracts using `cargo contract`.\n\n## Development\n\nBelow you can find some base commands, for more information check [official documentation](https://use.ink/).\n\n### Format code\n\n```sh\ncargo +nightly fmt\n```\n\n### Run clippy linter\n\n```sh\ncargo +nightly clippy --all-features\n```\n\n### Check that smart contracts build to WASM\n\n```sh\ncargo contract check\n```\n\n### Testing\n\n```sh\ncargo test --features e2e-tests\n```\n\n### Build smart contracts\n\n```sh\ncargo contract build --release\n```\n\n### Run pre-commit\n\n```sh\npre-commit run --all-files\n```\n\n## CI Jobs\n\nThis repository contains predefined GitHub actions for quality assurance.\n\n### GitHub runners\n\n-   Linux -\u003e `ubuntu-20.04`\n\n### Jobs\n\n-   Formatting check -\u003e `cargo +nightly fmt --check`\n-   Linter check -\u003e `cargo +nightly clippy --all-features`\n-   Building smart contracts -\u003e `cargo contract build`\n-   Testing smart contracts -\u003e `cargo test --features e2e-tests`\n-   Integration tests -\u003e `yarn test --exit`\n\n## Integration Tests\n\nThe integration tests for this project are written using [Cucumber.js](https://cucumber.io/docs/installation/javascript/).\n\nThe tests are defined in [features/](./features/).\nThe following files describe the tests and user stories using [Gherkin Syntax](https://cucumber.io/docs/gherkin/):\n\n-   [features/us1.feature](./features/us1.feature)\n-   [features/us2.feature](./features/us2.feature)\n-   [features/us3.feature](./features/us3.feature)\n\nThe test implementations are found in:\n\n-   [features/support/steps.js](./features/support/steps.js): the test definitions using `Cucumber.js`.\n-   [features/support/world.js](./features/support/world.js): the environment class used by the tests that manages interactions with Substrate and the contract.\n\n### Running Integration Tests\n\nFrom the project root\n\n1. Install dependencies:\n\n```\nyarn\n```\n\n2. Start `substrate-contracts-node` using [v0.24.0](https://github.com/paritytech/substrate-contracts-node/releases/tag/v0.24.0)\n\n```\nsubstrate-contracts-node --dev\n```\n\n3. Run the tests:\n\n```\nyarn test --exit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fco2-passport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparitytech%2Fco2-passport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fco2-passport/lists"}