@dfinity/cketh
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

cketh-js

A library for interfacing with ckETH on the Internet Computer.

npm version GitHub license

Table of contents

Installation

You can use cketh-js by installing it in your project.

npm i @dfinity/cketh

The bundle needs peer dependencies, be sure that following resources are available in your project as well.

npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils

Usage

The features are available through the class CkETHMinterCanister. It has to be instantiated with a canister ID.

import { CkETHMinterCanister } from "@dfinity/cketh";
import { createAgent } from "@dfinity/utils";

const agent = await createAgent({
  identity,
  host: HOST,
});

const { getSmartContractAddress } = CkETHMinterCanister.create({
  agent,
  canisterId: MY_CKETH_MINTER_CANISTER_ID,
});

const address = await getSmartContractAddress({});

Features

cketh-js implements following features:

🏭 CkETHMinterCanister

🔗 Source

Methods

⚙️ create
Method Type
create (options: CkETHMinterCanisterOptions<_SERVICE>) => CkETHMinterCanister

🔗 Source

⚙️ getSmartContractAddress

The address of the helper smart contract may change in the future when the minter is upgraded. Please verify the address of the helper contract before any important transfer by querying the minter as follows.

Method Type
getSmartContractAddress ({ certified, }?: QueryParams) => Promise<string>

Parameters:

  • params: The parameters to resolve the ckETH smart contract address.
  • params.certified: query or update call

🔗 Source

⚙️ withdrawEth

Submits a request to convert ckETH to ETH after making an ICRC-2 approval.

Preconditions:

The caller allowed the minter's principal to spend its funds using [icrc2_approve] on the ckETH ledger.

Method Type
withdrawEth ({ address, ...rest }: { address: string; amount: bigint; }) => Promise<RetrieveEthRequest>

Parameters:

  • params: The parameters to withdrawal ckETH to ETH.
  • params.address: The destination ETH address.
  • params.amount: The ETH amount in wei.

🔗 Source

⚙️ withdrawErc20

Submits a request to convert ckErc20 to Erc20 - e.g. ckUSDC to USDC - after making ICRC-2 approvals for the ckETH and related ckErc20 ledgers.

Preconditions:

The caller allowed the minter's principal to spend its funds using [icrc2_approve] on the ckErc20 ledger and to burn some of the user’s ckETH tokens to pay for the transaction fees on the CkETH ledger.

Method Type
withdrawErc20 ({ address, ledgerCanisterId, ...rest }: { address: string; amount: bigint; ledgerCanisterId: Principal; }) => Promise<RetrieveErc20Request>

Parameters:

  • params: The parameters to withdrawal ckErc20 to Erc20.
  • params.address: The destination ETH address.
  • params.amount: The ETH amount in wei.
  • params.ledgerCanisterId: The ledger canister ID of the ckErc20.

🔗 Source

⚙️ eip1559TransactionPrice

Estimate the price of a transaction issued by the minter when converting ckETH to ETH.

Method Type
eip1559TransactionPrice ({ certified, }: QueryParams) => Promise<Eip1559TransactionPrice>

Parameters:

  • params: The parameters to get the minter info.
  • params.certified: query or update call

🔗 Source

⚙️ retrieveEthStatus

Retrieve the status of a withdrawal request.

Method Type
retrieveEthStatus (blockIndex: bigint) => Promise<RetrieveEthStatus>

🔗 Source

⚙️ getMinterInfo

Returns internal minter parameters such as the minimal withdrawal amount, the last observed block number, etc.

Method Type
getMinterInfo ({ certified }: QueryParams) => Promise<MinterInfo>

Parameters:

  • params: The parameters to get the minter info.
  • params.certified: query or update call

🔗 Source

Resources

Package Sidebar

Install

npm i @dfinity/cketh

Weekly Downloads

308

Version

3.0.0

License

Apache-2.0

Unpacked Size

239 kB

Total Files

24

Last publish

Collaborators

  • dfx-json
  • dfn_wndlng
  • nathan.mcgrath.dfinity
  • frederikrothenberger
  • bitdivine
  • ielashi
  • dayyildiz
  • eric-swanson-dfinity
  • krpeacock
  • npm-dfinity-org