API

Carbon Retirement

The ECO carbon retirement API simplifies interacting with on-chain carbon markets by facilitating seamless, atomic purchase and retirement of a growing number of supported tokenized carbon offsets.

Programmatic Retirement Lifecycle

To complete the atomic retirement of an arbitrary amount of carbon, you must implement the following programmatic lifecycle:

  1. Parameterize the retirement request

  2. Broadcast the data and signature to the network for retirement

Parameterize

To programmatically retire carbon using the ECO API, users first create a RetireCarbonRequest.

Parameterize a retire carbon request for signature and broadcast

POST https://api.providepayments.com/api/v1/retire_carbon_requests

Request Body

{
    "id": "90638fe9-1433-4a09-89c6-4585ffde8ddf",
    "created_at": "2023-07-05T17:22:05.879751777Z",
    "application_id": "00000000-0000-0000-0000-000000000000",
    "organization_id": "00000000-0000-0000-0000-000000000000",
    "user_id": "40bc70bf-1140-4978-99bc-b8b800672842",
    "network_id": "2fd61fde-5031-41f1-86b8-8a72e2945ead",
    "data": "c8b9467e0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000002f800db0fdb5223b3c3f354886d907a671414a7f000000000000000000000000225b28c1a77fd4493196db19c538a44801243537000000000000000000000000000000000000000000000000000000000000343a00000000000000000000000000000000000000000000000000000000000001200000000000000000000000001480320db0aa1bbef15f847981e28776e7d2c442000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000750726f7669646500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000750726f7669646500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003048656c6c6f2066726f6d207468652050726f766964652045434f20636172626f6e207265746972656d656e742041504900000000000000000000000000000000",
    "hashed_data": "92437f706229414c6099d133f0a404dd9561dd5165e6b4055e635823ad438c75",
    "provider": "klima",
    "tx_hash": null,
    "pool_token_contract_address": "0x2f800db0fdb5223b3c3f354886d907a671414a7f",
    "source_token_contract_address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
    "project_token_contract_address": "0x225b28c1a77fd4493196db19c538a44801243537",
    "beneficiary_address": "0x1480320Db0aa1Bbef15f847981E28776E7D2c442",
    "beneficiary_name": "Provide",
    "description": "Hello from the Provide ECO carbon retirement API",
    "retire_by": "source",
    "retirement_message": "Hello from the Provide ECO carbon retirement API",
    "value": 0.01337
}

Sign

After creating a parameterized request that can be used to retire the specified amount of carbon, the transaction needs to be signed. We designed the API in this manner to ensure users can enable self-custody in their implementations. The signature over the transaction data returned by the parameterize request provides flexibility for (i) broadcasting the transaction and bearing the network transaction costs or (ii) leveraging the Managed Transactions API to broadcast the transaction while maintaining the ability to verify the original signer (e.g., by using ecrecover).

Broadcast

This final step in the process to programmatically retire carbon enables flexibility in systems and applications that would otherwise struggle to assemble, encode and broadcast transactions to the targeted network. The broadcast API accepts the unsigned data as returned by the Parameterize call and a hex-encoded signature.

The following code demonstrates how to broadcast parameterized and signed ECO transactions:

curl -i -XPOST \
    -H 'Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7fSwiZXhwIjpudWxsLCJpYXQiOjE1NTk4Nzg1NzQsImp0aSI6IjYzYTJkY2QzLWI5OTgtNDZjNC1hNzFkLTQ5MjU4YTBhYmEyMyIsInN1YiI6ImFwcGxpY2F0aW9uOmNiMjAzN2Y3LTc5ZmMtNDBmNC05NzIwLWFkYTYzNmRhNDE4MyJ9.NQLm__LbMWor-9GMG0LPcH4yQIbu9Uw70kJfRt1KP64' \
    -H 'Content-Type: application/json' \
    https://api.providepayments.com/api/v1/eco/retire_carbon_requests/90638fe9-1433-4a09-89c6-4585ffde8ddf/retire \
    -d '{
  "data": "c8b9467e0000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000002f800db0fdb5223b3c3f354886d907a671414a7f000000000000000000000000225b28c1a77fd4493196db19c538a44801243537000000000000000000000000000000000000000000000000000000000000343a00000000000000000000000000000000000000000000000000000000000001200000000000000000000000001480320db0aa1bbef15f847981e28776e7d2c442000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000750726f7669646500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000750726f7669646500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003048656c6c6f2066726f6d207468652050726f766964652045434f20636172626f6e207265746972656d656e742041504900000000000000000000000000000000",
  "signature": "4bf45a05a078d2fbd18996ce50f001d3841121b86e6026edff83b5b2aac949f74588378d001687b1b5c85460851952fabb93778c681a4a209a9cf5f25e94823400",
  "signer": "0xc9327CB2982cb0B7922670DeF04a11aE5A4E0479"
}'

The broadcast method provides guarantees around atomicity and double-spend protection, ensuring each parameterized carbon retirement request is only executed once. Subsequent attempts to broadcast the same request will fail with a 422 status code. Here is an example response to an API call attempting to retire a parameterized transaction:

{
  "message": "retire carbon request has already been broadcast; tx hash: 584205679a00025e927fc24ef0a3a5e726017392395e7d027b3936d7e644d0ca"
}

Fetch Carbon Retirement

You can retrieve details related to an existing RetireCarbonRequest, including links to generated certificates and verifiable credentials, if applicable.

GET https://api.providepayments.com/api/v1/eco/retire_carbon_requests/:id

Path Parameters

{
    "id": "90638fe9-1433-4a09-89c6-4585ffde8ddf",
    "created_at": "2023-07-05T17:22:05.879752Z",
    "application_id": "00000000-0000-0000-0000-000000000000",
    "organization_id": "00000000-0000-0000-0000-000000000000",
    "user_id": "40bc70bf-1140-4978-99bc-b8b800672842",
    "network_id": "2fd61fde-5031-41f1-86b8-8a72e2945ead",
    "provider": "klima",
    "tx_hash": "0xc93d7ce4c67a238fb1a2b83d607405798b7ec20e3e5bad7f824af80783338f7c",
    "pool_token_contract_address": "0x2f800db0fdb5223b3c3f354886d907a671414a7f",
    "source_token_contract_address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
    "project_token_contract_address": "0x225b28c1a77fd4493196db19c538a44801243537",
    "beneficiary_address": "0x1480320Db0aa1Bbef15f847981E28776E7D2c442",
    "beneficiary_name": "Provide",
    "description": "Hello from the Provide ECO carbon retirement API",
    "retire_by": "source",
    "retirement_message": "Hello from the Provide ECO carbon retirement API",
    "value": 0.01337,
    "certificate_href": "https://www.carbonmark.com/en/retirements/0x1480320Db0aa1Bbef15f847981E28776E7D2c442/3",
    "certificate_href_alt": "https://klimadao.finance/en/retirements/0x1480320Db0aa1Bbef15f847981E28776E7D2c442/3"
}

Note that the returned RetireCarbonRequest details will contain a non-null tx_hash and cardinality if the request has been successfully broadcast to the network for settlement. The returned cardinality represents the serial position of the completed carbon retirement for the provider for the associated beneficiary_address.

Similarly, the certificate_href and verifiable_credentials_href fields will only be included in the response if the underlying RetireCarbonRequest has been successfully retired and the provider supports those resources on the settlement network.

Some provider implementations may support an additional certificate_href_alt field.

Last updated