npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ccamp/lib

v1.11.3

Published

The javascript library for interacting with the ccamp

Downloads

73

Readme

CCAMPClient Documentation

The CCAMPClient is a TypeScript class designed to streamline interactions with various CCAMP canisters, including the Remittance canister, the Data collection canister, and the Protocol data collection canister. This class enables users to engage with Data Collection, Protocol Data Collection, and Remittance canisters on the IC network using Ethereum-based private keys.

Table of Contents

  • Installation
  • Usage
    • Constructor
    • getCanisterInstance
    • approveLockerContract
    • deposit
    • withdraw

Installation

Ensure you have the necessary dependencies installed:

npm install

Usage

The CCAMPClient is versatile, supporting both development and production environments. This flexibility is achieved by providing an optional options parameter to the constructor. The env property within this parameter allows users to specify the environment, determining which network the CCAMP canisters will be instantiated on. By default, the environment is set to prod for production, but users can easily switch to local for development. Example usage:

Constructor

constructor(ethereumPrivateKey: string, options?: { env?: Environment })
  • ethereumPrivateKey: Private key for the Ethereum account.
  • options.env: Environment (default is ENV.prod). Options: prod or local.
const ccampClient = new CCAMPClient('your_ethereum_private_key', { env: ENV.prod });

getCanisterInstance

getCanisterInstance(canisterType: CanisterType, overrides?: { canisterId?: string }): any
  • canisterType: Type of the IC canister (e.g., CANISTER_TYPES.DATA_COLLECTION).
  • overrides.canisterId: Override the default canister ID.
const dataCollectionCanister = ccampClient.getCanisterInstance(CANISTER_TYPES.DATA_COLLECTION);

approveLockerContract

Approve the locker contract to spend tokens on your behalf.

approveLockerContract(erc20TokenAddress: string, amountToApprove: ethers.BigNumberish, signer: ethers.Wallet, overrides?: { lockerContract?: string }): Promise<any>
  • erc20TokenAddress: Ethereum address of the ERC20 token.
  • amountToApprove: Amount to approve for the locker contract.
  • signer: Ethereum Wallet signer.
  • overrides.lockerContract: Override the default locker contract address.
await ccampClient.approveLockerContract('token_address', amount, signer);

deposit

Deposit funds into the protocol.

deposit(amount: ethers.BigNumberish, tokenAddress: string, signer: ethers.Wallet, overrides?: { lockerContract?: string; dcCanister?: string }): Promise<Transaction>
  • amount: Amount to deposit.
  • tokenAddress: Ethereum address of the token.
  • signer: Ethereum Wallet signer.
  • overrides.lockerContract: Override the default locker contract address.
  • overrides.dcCanister: Override the default data collection canister ID.
await ccampClient.deposit(amount, 'token_address', signer);

withdraw

Withdraw funds from the network.

withdraw(amount: ethers.BigNumberish, tokenAddress: string, chain: string ,signer: ethers.Wallet, overrides?: { lockerContract?: string; dcCanister?: string; remittanceCanister?: string }): Promise<Transaction>
  • amount: Amount to withdraw.
  • tokenAddress: Ethereum address of the token.
  • chain: Blockchain identifier.
  • signer: Ethereum Wallet signer.
  • overrides.lockerContract: Override the default locker contract address.
  • overrides.dcCanister: Override the default data collection canister ID.
  • overrides.remittanceCanister: Override the default remittance canister ID.
await ccampClient.withdraw(amount, 'token_address', signer, 'ethereum');

Types

Below are the types used in the CCAMPClient class:

Environment

export type Environment = 'prod' | 'dev';
  • prod: Production environment.
  • dev: Development environment.

CanisterType

export type CanisterType = 'dataCollection' | 'protocolDataCollection' | 'remittance';
  • dataCollection: Type for Data Collection canister.
  • protocolDataCollection: Type for Protocol Data Collection canister.
  • remittance: Type for Remittance canister.

Canister Instances

export type DataCollectionCanister;
export type ProtocolDataCollectionCanister;
export type RemittanceCanister;
  • DataCollectionCanister: Type for Data Collection canister instance.
  • ProtocolDataCollectionCanister: Type for Protocol Data Collection canister instance.
  • RemittanceCanister: Type for Remittance canister instance.

These types are integral to the proper functioning of the CCAMPClient.getCanisterInstance method, providing a more specific interface for the different canister types.

This documentation provides a brief overview of the CCAMPClient class and its methods. Refer to the inline comments in the code for more detailed explanations of each method and its parameters.