Toucan
Search
⌃K

Quickstart

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.
import ToucanClient from "toucan-sdk";
​
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");
toucan.setProvider(provider);
toucan.setSigner(signer);
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 Ubeswap, which you need to redeem for TCO2s. You can then retire these and get a certificate for that. If you already own NCTs, you can follow this example. In case you don't and are developing on testnet, you can also just get some 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.redeemAuto2("NCT", parseEther("1"));
Retire the Carbon Credits
await toucan.retire(parseEther("1"), tco2addresses[0].address);