Marvin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Toucan Protocol in depth This in depth Toucan Protocol summary has the following section. 1. [Creating TCO2 tokens](https://hackmd.io/Z06Ad5ezTga8sOsqh3DvkA#Creating-TCO2-tokens) 2. Creating BCT tokens 3. Retiring TCO2 tokens ## Creating TCO2 tokens ### 1. CarbonOffsetBatches.mintEmptyBatch() #### Overview - increments `batchTokenCounter` - creates new `newItemId` from `batchTokenCounter` - mint ERC721 token on the basis of the `newItemId` as `tokenId` to the address provided in the parameters - set retirement status of newly minted token to `RetirementStatus.Pending` *All the mappings and state variables are stored in the contract `CarbonOffsetBatchesStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatchesStorage.sol)* #### Inputs 1. `to`: `Address` - Address to which the ERC721 token is to be minted #### Require & Modifiers - `whenNotPaused` - contract can not be paused #### Output None #### Events ` event BatchMinted(address sender, uint256 tokenId); ` #### Function Prototype ```javascript= function mintEmptyBatch(address to) external virtual whenNotPaused { ``` *[link to function](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatches.sol#L236)* ### 2. CarbonProject.addNewProject() #### Overview - sets new `projectId` to true in various mappings - increments `totalSupply` & `projectTokenCounter` - creates `newItemId` from `projectTokenCounter` and stores in a mapping - mint ERC721 token on the basis of the `newItemId` as `tokenId` to the address provided in the parameters - stores all the parameters in the mapping `projectData[newItemId]...` *All the mappings and state variables are stored in the contract `CarbonProjectStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonProjectsStorage.sol)* #### Inputs 1. `to`: `Address` - Address to which the ERC721 token is to be minted 2. `projectId`: `String` - **Question** this data is either from off-chain carbon offset companies or created through Toucan? Same for all below 3. `standard` : `String` - 4. `methodology`: `String` - 5. `region `: `String` - 6. `storageMethod`: `String` - 7. `method`: `String` - 8. `emissionType`: `String` - 9. `category`: `String` - 10. `uri`: `String` - metadata #### Require & Modifiers - `whenNotPaused` - contract can not be paused - `onlyManager` - can only be called by the owner or address with `MANAGER_ROLE` role - `projectId` != `''` - `projectId` can not already exist #### Output - `newItem`: `uint256` - new project token ID that has been used as `tokenId` to mint the Carbon Project ERC721 #### Events `event ProjectMinted(address receiver, uint256 tokenId); ` #### Function prototype ```javascript= function addNewProject( address to, string memory projectId, string memory standard, string memory methodology, string memory region, string memory storageMethod, string memory method, string memory emissionType, string memory category, string memory uri ) external virtual override onlyManagers whenNotPaused returns (uint256) ``` *[link to function](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonProjects.sol#L104)* ### 3. CarbonProjectVintage.addNewVintage() #### Overview - sets new `projectId` to true in various mappings - increments `totalSupply` & `projectVintageTokenCounter` - creates `newItemId` from `projectVintageTokenCounter` and stores in a mapping - mint ERC721 token on the basis of the `newItemId` as `tokenId` to the address provided in the parameters - stores all the parameters in the mapping `vintageData[newItemId]...` - stores the `newItemId` to the mapping `pvTokTokenId[projectTokenId][startTime]` *All the mappings and state variables are stored in the contract `CarbonProjectVintageStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonProjectVintagesStorage.sol)* #### Inputs 1. `to`: `Address` - Address to which the ERC721 token is to be minted 2. `projectTokenId`: `uint256` - `tokenId` used in creation of the Carbon Project ERC721 3. `name` : `string` - Name of the Carbon Project Vintage on the 4. `startTime`: `uint64` - Start time of the duration of the vintage 5. `endTime `: `uint64` - End time or experation time of the vintage 6. `totalVintageQuantity`: `uint64` - Amount of Vintage to be retired 7. `isCorsiaCompliant`: `bool` - 8. `isCCPcompliant`: `bool` - 9. `coBenefits`: `string` - 10. `correspAdjustment`: `string` - 11. `additionalCertification`: `string` - 12. `uri`: `string` - metadata #### Require & Modifiers - `whenNotPaused` - contract can not be paused - `onlyManager` - can only be called by the owner or address with `MANAGER_ROLE` role - `startTime < endTime` - `pvToTokenId[projectTokenId][startTime] == 0` - Vintage already added #### Output - `newItem`: `uint256` - new project vintage token ID that has been used as `tokenId` to mint the Carbon Project ERC721 #### Events ```javascript= event ProjectVintageMinted( address receiver, uint256 tokenId, uint256 projectTokenId, uint64 startTime ); ```` #### Function prototype ```javascript= function addNewVintage( address to, uint256 projectTokenId, string memory name, uint64 startTime, uint64 endTime, uint64 totalVintageQuantity, bool isCorsiaCompliant, bool isCCPcompliant, string memory coBenefits, string memory correspAdjustment, string memory additionalCertification, string memory uri ) external virtual override onlyManagers whenNotPaused returns (uint256) ``` *[link to function](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonProjectVintages.sol#L101)* ### 4.CarbonOffsetBatches.updateBatchWithData() #### Overview - sets `seriealNumber` & `quantity` *All the mappings and state variables are stored in the contract `CarbonOffsetBatchesStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatchesStorage.sol)* #### Inputs 1. `tokenId`: uint256 - ID of the project vintage ERC721 token 2. `serialNumber`: `string` - official serial number returned when retiring the carbon offset off-chain 3. `quantity`: `uint256` - amount that has been retired off-chain, to be transferred on-chain 4. `uri`: `string` - metadata #### Require & Modifiers - `whenNotPaused` - contract can not be paused - `msg.sender` == `owner` || `msg.sender` == `VERIFIER_ROLE` - batchNFT status != ` RetirementStatus.Confirmed` - `serialNumber` != already been approved - `URIs[uri]` == `false` - metadata does not already exist #### Output None #### Events ```javascript= event BatchUpdated(uint256 tokenId, string serialNumber, uint256 quantity); ``` #### Function prototype ```javascript= function updateBatchWithData( uint256 tokenId, string memory serialNumber, uint256 quantity, string memory uri ) public virtual whenNotPaused ``` *[link to function](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatches.sol#L247)* ### 5.CarbonOffsetBatches.confirmRetirementWithVintage() #### Overview - stores the `projectVintageTokenId` into the mapping `nftList[tokenId]` - - sets the serial number to `true`, so retirement can not be double spend - sets the retirement to `RetirementStatus.Confirmed` for the BatchNFT *All the mappings and state variables are stored in the contract `CarbonOffsetBatchesStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatchesStorage.sol)* #### Inputs 1. `tokenId`: `uint256` - Batch token ID to confirm the retirement on 2. `projectVintageTokenId`: `uint256` - Project Vintage token ID to link the BatchNFT to #### Require & Modifiers - `whenNotPaused` - contract can not be paused - - `onlyvVerifier` - can only be called by the owner or address with `VERIFIER_ROLE` role - `nftList[tokenId].status` != `RetirementStatus.Confirmed` - Can not retire BatchNFT twice - `nftList[tokenId].projectVintageTokenId` != `0` - cannot retire batch without project vintage - check if the `projectVintageTokenId` exists in the `contractRegistry` - `tokenId` exists - `serialNumberExist[nftList[tokenId].serialNumber]` == `false` - serial number cannot already been approved #### Output None #### Events ```javascript= event BatchLinkedWithVintage( uint256 tokenId, uint256 projectVintageTokenId ); ``` #### Function prototype ```javascript= function confirmRetirementWithVintage( uint256 tokenId, uint256 projectVintageTokenId ) public virtual onlyVerifier whenNotPaused ``` *[link to function](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatches.sol#L200)* ### 6.ToucanCarbonOffsetsFactory.deployFromVintage() #### Overview - creates signature and payload that will be used to deploy new TCO2 contract, on the basis of `projectVintageTokenId` - deployes new TCO2 contract and adds it's address to the `ToucanContractRegistry` - stored the address in local array `deployedContracts` and mapping `pvIdtoERC20[projectVintageTokenId]` *All the mappings and state variables are stored in the contract `ToucanCarbonOffsetsFactoryStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/ToucanCarbonOffsetsFactoryStorage.sol)* #### Inputs 1. `projectVintageTokenId`: `uint256` - token ID from the ERC721 project vintage token #### Require & Modifiers - `whenNotPaused` - contract can not be paused - `beacon` != `address(0)` - beacon that tracks the current implementation has not been set - `!checkExistence(projectVintageTokenId)` - check that `projectVintageTokenId` has not already been used to create a TCO2 contract - check if the `projectVintageTokenId` exists in the `contractRegistry` #### Output None #### Events ```javascript= event TokenCreated(uint256 vintageTokenId, address tokenAddress); ``` #### Function prototype ```javascript= function deployFromVintage(uint256 projectVintageTokenId) public virtual whenNotPaused ``` [*link to function*](https://github.com/CO2ken/contracts/blob/main/contracts/ToucanCarbonOffsetsFactory.sol#L128) ### 7.CarbonOffsetBatches.fractionalize() #### Overview - transfers the BatchNFT that is linked to the project vintage to the `ToucanCarbonOffset` contract to be fractionalized #### Inputs 1. `tokenId`: `uint256` - token ID to be transferred #### Require & Modifiers - `_isApprovedOrOwner(_msgSender(), tokenId)` - ERC721 token is approved by the owner, or transfer is called by the owner self - `nftList[tokenId].status` == `RetirementStatus.Confirmed` - retirement has been confirmed for the BatchNFT token linked to the `tokenId` #### Output None #### Events None #### Function prototype ```javascript= function fractionalize(uint256 tokenId) external virtual ``` [*link to function*](https://github.com/CO2ken/contracts/blob/main/contracts/CarbonOffsetBatches.sol#L363) ### 8. ToucanCarbonOffset.onERC721Received() *This function gets triggerd after the function `fractionalize` has been called* #### Overview - check if the attributes of the received ERC721 token matches the attributes stored in the TCO2 contract - stores the `tokenId` in the mapping `minterToId[from]` - mint the quantity ERC20 tokens that match the quantity offset to the `from` address *All the mappings and state variables are stored in the contract `ToucanCarbonOffsetsStorage.sol`. [link to file](https://github.com/CO2ken/contracts/blob/main/contracts/ToucanCarbonOffsetsStorage.sol) #### Inputs 1. `address` - /* operator */ 2. `from`: `address` - msg.sender 3. `tokenId`: `uint256` - token ID of the BatchNFT 4. `bytes calldata` - /* data */ #### Require & Modifiers - `whenNotPaused` - contract can not be paused - ` checkWhiteListed(msg.sender)` - the BatchNFT is from a whitelisted TCO2 contract - `checkMatchingAttributes(projectVintageTokenId)` - the attributes of the TCO2 contract match the once from the received ERC721 token - `status == RetirementStatus.Confirmed` - the retirement status of the BatchNFT has ben confirmed - `remainingSpace > quantity` - the quantity in Batch is not higher then total vintages #### Output ```javascript= return this.onERC721Received.selector ``` #### Events None #### Function prototype ```javascript= function onERC721Received( address, /* operator */ address from, uint256 tokenId, bytes calldata /* data */ ) external virtual override whenNotPaused returns (bytes4) ``` [*link to function*](https://github.com/CO2ken/contracts/blob/main/contracts/ToucanCarbonOffsets.sol#L122) ## Creating BCT tokens WIP ## Retiring TCO2 tokens WIP

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully