{"id":18298019,"url":"https://github.com/detrash/recy-contract","last_synced_at":"2025-04-05T13:33:00.392Z","repository":{"id":188327344,"uuid":"496232504","full_name":"detrash/recy-contract","owner":"detrash","description":"RECY Network smart contracts to clean the world.","archived":false,"fork":false,"pushed_at":"2024-12-30T01:53:47.000Z","size":1846,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-21T05:04:32.459Z","etag":null,"topics":["smartcontract","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/detrash.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":"2022-05-25T13:00:26.000Z","updated_at":"2024-12-30T01:53:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"a07bdcfb-53cf-4646-972b-d7705cc28f75","html_url":"https://github.com/detrash/recy-contract","commit_stats":null,"previous_names":["detrash/contractdetrash","detrash/detrash-contract","detrash/recy-contract"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detrash%2Frecy-contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detrash%2Frecy-contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detrash%2Frecy-contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/detrash%2Frecy-contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/detrash","download_url":"https://codeload.github.com/detrash/recy-contract/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247342442,"owners_count":20923603,"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":["smartcontract","solidity"],"created_at":"2024-11-05T15:05:00.821Z","updated_at":"2025-04-05T13:33:00.374Z","avatar_url":"https://github.com/detrash.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RECY Network smart contract\n\n[![CI](https://github.com/detrash/detrash-contract/actions/workflows/ci.yml/badge.svg)](https://github.com/detrash/detrash-contract/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/detrash/detrash-contract/graph/badge.svg?token=MDYJB5LOWI)](https://codecov.io/gh/detrash/detrash-contract)\n\nThis project is bootstrapped with Hardhat, a development environment for Ethereum smart contracts.\n\n## Development\n\n1. Install dependencies\n\n   ```bash\n   yarn\n   ```\n\n2. Compile contracts\n\n   ```bash\n   yarn compile\n   ```\n\n3. Test contracts\n\n   ```bash\n   yarn test\n   ```\n\n## Deploy\n\n1. Contracts can be deployed on any EVM network. To deploy contracts, you need to set up a `.env` file with the following variables\n\n   ```bash\n   HARDHAT_PRIVATE_KEY=0x...\n   ```\n\n2. Deploy contracts\n\n\u003e [!NOTE]\n\u003e Currently arguments for deployment are hardcoded in the scripts. You can change them in the scripts before deploying.\n\n| Script            | Description                 | Arguments                  |\n| ----------------- | --------------------------- | -------------------------- |\n| `deploy-all`      | Deploy all contracts        |                            |\n| `deploy-crecy`    | Deploy CRECY ERC20 contract | totalSupply, initialSupply |\n| `deploy-fcw`      | Deploy FCW ERC721 contract  |                            |\n| `deploy-timelock` | Deploy timelock contract    | crecy address              |\n\n| Network     | Description      |\n| ----------- | ---------------- |\n| `localhost` | Hardhat localnet |\n| `celo`      | CELO mainnet     |\n| `alfajores` | CELO testnet     |\n\n```bash\nyarn hardhat run scripts/\u003cscript\u003e.ts --network \u003cnetwork\u003e\n```\n\nVerify smart contract codes on explorer\n\n```bash\nyarn hardhat verify --network \u003cnetwork\u003e \u003caddress\u003e\n```\n\n## Deployed Addresses\n\n| Contract Name      | Network | Address                                                                                                                          |\n| ------------------ | ------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| cRECY              | Celo    | [0x34C11A932853Ae24E845Ad4B633E3cEf91afE583](https://explorer.celo.org/mainnet/token/0x34C11A932853Ae24E845Ad4B633E3cEf91afE583) |\n| DeTrashCertificate | Polygon | [0xbc68c4ec4182e1d2c73b5e58bd92be9871db2230](https://polygonscan.com/token/0xbc68c4ec4182e1d2c73b5e58bd92be9871db2230)           |\n| TimeLock\t\t\t | Celo    | [0x2B7D8711E26E78218791B85EdB1ff4EFf1A8BF54](https://celoscan.io/address/0x2b7d8711e26e78218791b85edb1ff4eff1a8bf54)\n| RecyCertificate    | Celo    | [0xd574e0605c20Fc683feDBDD01ce745fF2C1a6f40](https://celoscan.io/address/0xd574e0605c20fc683fedbdd01ce745ff2c1a6f40)\n\n### Testnet\n\n| Contract Name   | Address                                                                                                                        |\n| --------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| CRecy           | [0x004c368A3fb45b0CD601e2203Fd2948D9d695a3b](https://alfajores.celoscan.io/address/0x004c368A3fb45b0CD601e2203Fd2948D9d695a3b) |\n| FCWStatus       | [0xbf10E8d903bB4fcc705740d37d5668e2d5A6CBbC](https://alfajores.celoscan.io/address/0xbf10E8d903bB4fcc705740d37d5668e2d5A6CBbC) |\n| RecyCertificate | [0x56A396a452f4F44412f089Efc3c4bF27aE6B5423](https://alfajores.celoscan.io/address/0x56A396a452f4F44412f089Efc3c4bF27aE6B5423) |\n| TimeLock (deprecated)       | [~~0x64604b6564862d4544583943A108d948916CD2ec~~](https://alfajores.celoscan.io/address/0x64604b6564862d4544583943A108d948916CD2ec) |\n\n# TimeLock Guide\n\nThis document describes how to interact with the Lock Contract in the cRecy ecosystem. This implementation considers the existence of the following contracts:\n\n - TimeLock: the contract responsible for keeping tokens during lock period and for emitting NFT certificates.\n - CRecy: the ERC-20 CRecy token\n - RecyCertificate: the NFT for each certificate\n - FCWStatus: the Friends of the Clean World contract\n\nThe CRecy and RecyCertificate addresses are passed as parameters during the TimeLock initialization. It supports the following roles:\n\n- ADMIN_ROLE\n- OPERATOR_ROLE\n- PAUSER_ROLE\n\nThe current version of the contract is published on Celo Network in the following address: [0x2B7D8711E26E78218791B85EdB1ff4EFf1A8BF54](https://celoscan.io/address/0x2B7D8711E26E78218791B85EdB1ff4EFf1A8BF54).\n\n## Certificate Creation\n\nEvery certificate submitted to the Lock Contract needs to be signed according to the [EIP-712](https://eips.ethereum.org/EIPS/eip-712). Each certificate should be an object with the following data and types:\n\n    CertificateAuthorization: [\n              { name: \"institution\", type: \"bytes32\" },\n              { name: \"tons\", type: \"uint8\" },\n              { name: \"baseYear\", type: \"uint16\" },\n              { name: \"baseMonth\", type: \"uint8\" },\n              { name: \"timespan\", type: \"uint8\" },\n              { name: \"signer\", type: \"address\" },\n              { name: \"authorization\", type: \"bytes32\" },\n              { name: \"deadline\", type: \"uint256\" },\n    ]\n\nThe first 5 fields are related to the certificate itself, while the last 3 are used to validate the signature on-chain, as follows:\n\n-  `signer`: address of the account that will sign the certificate. Should have `ADMIN_ROLE` or `OPERATOR_ROLE` in the Lock Contract\n- `authorization`: a unique control number in hex format for each authorization\n- `deadline`: the date until that certificate can be presented to the Lock Contract\n\n## Signing Process\n\nEach signature should also contain the message, the `CertificateAuthorization` types object, and the following domain:\n\n    {\n          chainId: 31337,\n          name: \"GenericTypedMessage\",\n          version: \"1\",\n          verifyingContract: \"0x2B7D8711E26E78218791B85EdB1ff4EFf1A8BF54\"\n     }\n\nThe signature process requires an account with `ADMIN_ROLE` or `OPERATOR_ROLE` to generate the signed message. It can be accomplished via a script or via a DApp, where signers can connect their EOA using solutions such as [Metamask](https://metamask.io), [Wallet Connect](https://walletconnect.network/) or any other equivalent solution.\n\nHere, we provide an example using [Ethers.js](https://docs.ethers.org/v6/) with a randomly created account:\n\n    import moment from \"moment\";\n    import { HDNodeWallet } from \"@ethersproject/wallet\"\n    import { fromRpcSig } from 'ethereumjs-util';\n    import { doLock } from \"./lockUtils.js\"\n    \n    certTypedMessage = {\n       domain: {\n         chainId: 31337,\n         name: \"GenericTypedMessage\",\n         version: \"1\",\n         verifyingContract: \"0x2B7D8711E26E78218791B85EdB1ff4EFf1A8BF54\"\n       },\n       message: {\n         institution: ethers.encodeBytes32String(\"Acme Inc.\"),\n         tons: '3',\n         baseYear: '2024',\n         baseMonth: '1',\n         timespan: '12',\n         signer: admin.address,\n         authorization: `0x1`,\n         deadline: moment().add(1, 'day').format('X')\n       },\n       types: {\n         CertificateAuthorization: [\n           { name: \"institution\", type: \"bytes32\" },\n           { name: \"tons\", type: \"uint8\" },\n           { name: \"baseYear\", type: \"uint16\" },\n           { name: \"baseMonth\", type: \"uint8\" },\n           { name: \"timespan\", type: \"uint8\" },\n           { name: \"signer\", type: \"address\" },\n           { name: \"authorization\", type: \"bytes32\" },\n           { name: \"deadline\", type: \"uint256\" },\n         ],\n       },\n     };\n     const wallet = HDNodeWallet.createRandom();\n     const amount = 100; // A value to be defined\n     wallet.signTypedData(\n\t     certTypedMessage.domain,\n\t     certTypedMessage.types,\n\t     certTypedMessage.message\n     ).then( async (signedCertificate) =\u003e {\n\t     const rsvSignedCertificate = fromRpcSig(signedCertificate);\n\t     await doLock(amount, certTypedMessage.message, rsvSignedCertificate);\n     });\n\n## Locking a certificate\n\nTo lock a certificate in the Lock Contract, it is necessary to meet the following conditions:\n\n- Having a signed, not used, not expired, certificate `{ r, s, v}` components\n- Approval from certificate receiving account for the Lock Contract to move at least the amount of CRecy tokens to be locked on their behalf\n\nAny account can call a lock procedure in the Lock Contract passing the lock amount, the certificate data and the signature. Ahead, we provide the `lockUtils.js` script that exports a function to lock an amount in CRecy and a certificate in the contract.\n\n    import { Contract } from  \"@ethersproject/contract\";\n    import lockContractAbi from \"./lockContractAbi.json\";\n\t\n\texport const doLock (amount, certificate, signature) =\u003e {\n\t\tconst contract = new Contract(\"0x2B7D8711E26E78218791B85EdB1ff4EFf1A8BF54\", lockContractAbi);\n\n\t\tcontract.lock(amount, certificate, signature);\n\t}\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdetrash%2Frecy-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdetrash%2Frecy-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdetrash%2Frecy-contract/lists"}