# CELO: Integration Demo

### Prerequisites

Before retiring a Regen Credit, ensure you have the following:

* [ ] **CELO or cUSD Wallet**: A compatible wallet with sufficient **CELO** or **cUSD** balance.
* [ ] **Access to a User Interface (Optional)**: Tools like [Regen Atlas](https://regenatlas.xyz) can simplify the transaction process.
* [ ] **API Access (For Developers)**: Familiarity with RESTful APIs for integrating project data.
* [ ] **Project-Specific Wallet Address**: The unique wallet address linked to the Regen Credit you intend to retire.

***

### **DEMO**

{% embed url="<https://youtube.com/shorts/8e-ZToV7-jg?feature=share>" %}

***

### Step 1: Access Project & Credit Metadata

**Objective**: Retrieve essential information about the Regen Credit and associated project using the EcoToken Projects API.

1\. Access the Projects Endpoint

Utilize the EcoToken Projects API to fetch detailed project information.

* **Endpoint URL**:\
  `https://api.ecotoken.earth`

2\. Retrieve Metadata

Make a **GET** request to the projects endpoint to obtain a list of active projects and their associated metadata.

* **Response**:

```json
{
  "projects": [
    {
      "ID": "4",
      "active": true,
      "batch": "BT01-001-20210309-20231212-001",
      "description": "El Globo is located in the “Cuchilla Jardín-Támesis” Integrated Management District (DMI). Here ecosystem preservation, forest enhancement and restoration activities are implemented to generate positive and permanent impacts on biodiversity. The project has a 30-year financial, technical and legal structure for operation, securing biodiversity gains in time. The area has one of the few remnants of Native High Andean Forest still preserved in the region and it is a registered Habitat Bank at the Ministry of Environment and Sustainable Development of Colombia.",
      "escrow": "regen1qyg8d3usj0gjlmag6ns8wmp52m653kv7hrevuh",
      "image": "https://ccep-files.s3.amazonaws.com/el_globo.png",
      "image_nft": "https://ccep-files.s3.amazonaws.com/el_globo_nft.png",
      "location": "Cuchilla Jardín-Támesis District (DMI), Colombia",
      "name": "El Globo Habitat Bank",
      "order": 3,
      "price": 25,
      "registry": "Regen",
      "type": "Biodiversity",
      "uri": "https://app.regen.network/project/BT01-001",
      "solana_wallet": "AqqVKj2BgQsTGqvCKnvjTv9TeXniWaoENR1GSPnbbsLu",
      "celo_wallet": "0x614bA28f42A89a56dDdA6C002bbFFf14C0fd2c27",
      "aptos_wallet": "0xdad47d946195f2e47b107775e20a99e01f8eadfa45f720ceef82354845f7b3eb",
      "polygon_wallet": "",
      "eclipse_wallet": "GJqJsjkG1cPy1Rdd9DARqKDTRyHrYNeZrMPEGcqdWGnW"
    }
  ]
}
```

#### 3. Select the Desired Project

Identify the project you wish to support by reviewing attributes such as `name`, `description`, `location`, and `type`. Ensure the project is active (`"active": true`).

4\. Extract Wallet Information

Obtain the `celo_wallet` address from the selected project’s metadata.

***

### Step 2: Execute CELO/cUSD Transaction

**Objective**: Transfer CELO or cUSD to the project-specific wallet to retire the desired credit.

#### 1. Choose Transaction Method

* **Direct Transfer**: Use your CELO wallet to send funds directly to the project's `celo_wallet`.
* **User Interface (UI)**: Utilize platforms like [Regen Atlas](https://regenatlas.xyz) for a streamlined process.

2\. Prepare the Transaction

* **Recipient Address**: Enter the `celo_wallet` address retrieved in Step 1.
* **Amount**: Specify the amount of CELO or cUSD that corresponds to the amount of credits you wish to retire (see the `price` field from project metadata).

3\. Confirm Transaction

Review transaction details carefully to ensure the recipient address and amount are correct.

4\. Send Payment

* Initiate the transfer from your wallet or through the UI.
* Await transaction confirmation on the CELO blockchain. This may take a few moments depending on network conditions.

***

### Step 3: Oracle & CCEP Processing

**Objective**: Validate and process the transaction to initiate the retirement of Regen Network credits.

#### 1. Transaction Detection

The Oracle monitors the CELO blockchain for ERC20 Smart Contract events for transfers of valid tokens to the project-specific wallets (`celo_wallet`).

**Note**: There is a minimum of $2 required to process a retirement. Transactions below this amount will be pooled and queued for retirement when the pool reaches a significant total.

#### 2. Initiated Retirement Flow

Upon successful validation, the Oracle triggers the **CCEP (Cross-Chain Communication Protocol)** to queue the retirement flow. The credit status changes to "retired" on the Regen Network, and a unique retirement hash is generated, ensuring it cannot be resold.

***

### Step 4: Obtain Proof of Retirement (Optional)

**Objective**: Secure verifiable proof that the Regen Credit has been successfully retired.

1\. Retrieve Transaction Hash

After the transaction is confirmed, obtain the unique transaction hash from your wallet or user interface.

2\. Submit to API Endpoint

Send the transaction hash to the ecoToken Retirement API to obtain a retirement hash.

* **Endpoint URL**:\
  `https://api.ecotoken.earth/?tx=123`
* **Sample Request**:

  ```http
  GET https://api.ecotoken.earth/?tx=123`
  ```

#### 3. Receive Retirement Hash

The API returns a retirement hash, serving as official proof of retirement.

***

**Successful Response:**

```json
{
  "validationResult": {
    "isValid": true,
    "status": "Delivered",
    "description": "3.0000 GLOUSD",
    "usdValue": "3",
    "beneficiary": "0x614bA28f42A89a56dDdA6C002bbFFf14C0fd2c27",
    "creditsRetired": "0.12",
    "retirementHash": "4E6A42BBA776B708E6427A91C28D2C044952CC0A0F94269497D30550C345BEF4"
  }
}
```

**Fail Response:**

```json
{
  "validationResult": {
    "isValid": false,
    "message": "Transaction not found"
  }
}
```

#### Troubleshooting Tips:

* **Allow 3-5 seconds** before retrieving a retirement hash. If you're a developer, you can poll the endpoint.
* **`isValid` returned "false"**: Likely due to network congestion. Poll the endpoint.
* **`status` returned "pending"**: Likely due to network congestion. Poll the endpoint.
* **`retirementHash` returned "empty"**: Check the `status` field. If it's "pending," poll the endpoint.
* **`usdValue` is less than $2**: No retirement hash will be provided, and the status will remain pending.

***

#### Blockchain Explorers:

ecoToken provides a scan tool that will immediately show a transaction and its status. After a retirement is successful, you can also view the retirement on the Regen Explorer if desired.

* **ecoToken Scan**: [scan.ecotoken.earth](https://scan.ecotoken.earth)
* **Regen Mintscan Explorer**: [Mintscan.io](https://mintscan.io)

***

## Celo Supported Tokens

| Token Name              | Contract Address                           |
| ----------------------- | ------------------------------------------ |
| **CELO**                | 0x471ece3750da237f93b8e339c536989b8978a438 |
| **USDGLO (Glo Dollar)** | 0x4f604735c1cf31399c6e711d5962b2b3e0225ad3 |
| **cUSD (Celo Dollar)**  | 0x765de816845861e75a25fca122bb6898b8b1282a |
| **USDC (Wormhole)**     | 0x37f750b7cc259a2f741af45294f6a16572cf5cad |
| **USDC (Circle)**       | 0xceba9300f2b948710d2653dd7b07f33a8b32118c |
| **USDT (Wormhole)**     | 0x617f3112bf5397d0467d315cc709ef968d9ba546 |
| **USDT on Celo**        | 0x48065fbbe25f71c9282ddf5e1cd6d6a887483d5e |

***

**For assistance or inquiries**, contact our support team: <support@ecotoken.earth>
