Ask or search…
Comment on page


Quickstart a project with carbon retirements with these few lines of code.

Setting up the client

Instantiate the ToucanClient and set a signer & provider to interact with our infrastructure.
We recommend using to use ethers.js ^5.6.4 for the signer and provider. When you are considering using wagmi, only versions under 1.0 will work as this library has not yet been upgraded to viem.


import ToucanClient from "toucan-sdk";
import { ethers } from "ethers";
// ethers signer and provider
const provider = new ethers.providers.JsonRpcProvider(
// make sure to set your private key in your .env file
const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
// set signer & provider
const toucan = new ToucanClient("alfajores", provider, signer);


import ToucanClient from "toucan-sdk";
import { useProvider, useSigner } from "wagmi";
// get signer & provider
const { data: signer } = useSigner();
const provider = useProvider();
// set signer & provider
const toucan = new ToucanClient("alfajores", provider, signer);
You could also set the signer/provider later if you prefer that. They are optional. But you will need to set them if you want to interact with contracts. The provider is read-only, while the signer allows both writing to and reading from the blockchain.
import ToucanClient from "toucan-sdk";
const toucan = new ToucanClient("alfajores");
If you don't have a signer nor a provider set, you can only interact with the subgraph.

Retire Carbon Credits

To retire Carbon Credits on mainnet, you will have to get Carbon Pool Tokens from a DEX like Uniswap. You'll then need to redeem the pool tokens for TCO2s. You can then retire these TCO2s and get a retirement certificate NFT for that.
If you already own NCTs, you can follow this example. Get your test tokens at the Toucan Faucet. You can find more ways to retire in this list of all SDK functions.
Redeem your Pool Tokens and get an array of redeemed TCO2s
const tco2addresses = await toucan.redeemAuto("NCT", parseEther("1"));
Retire the Carbon Credits
await toucan.retire(parseEther("1"), tco2addresses[0].address);

Offset Carbon Credits with the OffsetHelper

The functions in the OffsetHelper will abstract the following steps:
  • Exchange ERC20 tokens e.g., cUSD or USDC for pool tokens (e.g., NCT) at a DEX ( Uniswap and SushiSwap, etc. depending on the network)
  • Interact with the pool token contract to redeem the tokens for TCO2
  • Interact with the TCO2 token contract to retire the TCO2
Using these functions, you can easily offset. Bear in mind that using these functions will not let you choose a specific project to retire. Specifying your the project you want to retire, requires you to use the redeemMany function.
const cUSD = "0x765DE816845861e75A25fCA122bb6898B8B1282a";
const tx = await toucan.autoOffsetExactInToken(cUSD, "NCT", parseEther("0.01"));