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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lj92458/celo-ethers-wrapper

v0.4.2

Published

A minimal wrapper to make Ethers.JS compatible with the Celo network. I have added function fromEncryptedJson and fromEncryptedJsonSync to CeloWallet.ts

Downloads

4

Readme

celo-ethers-wrapper

A minimal wrapper to make Ethers.JS compatible with the Celo network. I have added function fromEncryptedJson and fromEncryptedJsonSync to CeloWallet.ts

Install

npm i @lj92458/celo-ethers-wrapper

or

yarn add @lj92458/celo-ethers-wrapper

Note this wrapper has Ethers v5 as a peer dependency. Your project must include a dependency on that as well.

Basic Usage

Connect to the network by creating a CeloProvider, which is based on JsonRpc-Provider:

import { CeloProvider } from '@lj92458/celo-ethers-wrapper'

// Connecting to Alfajores testnet
const provider = new CeloProvider('https://alfajores-forno.celo-testnet.org')
await provider.ready

Note: for a more efficient provider based on StaticJsonRpcProvider you can use StaticCeloProvider instead.

Next, Create a CeloWallet, which is based on Wallet :

import { CeloWallet } from '@lj92458/celo-ethers-wrapper'

const wallet = new CeloWallet(YOUR_PK, provider)

Use the provider or wallet to make calls or send transactions:

const txResponse = await wallet.sendTransaction({
    to: recipient,
    value: amountInWei,
  })
const txReceipt = await txResponse.wait()
console.info(`CELO transaction hash received: ${txReceipt.transactionHash}`)

Contract Interaction

CeloWallet can be used to send transactions.

Here's an example of sending cUSD with the StableToken contract. For interacting with contracts you need the ABI and address. Addresses for Celo core contracts can be found with the CLI's network:contracts command. The ABIs can be built from the solidity code or extracted in ContractKit's generated folder.

import { Contract, ethers, utils, providers } from 'ethers'

const stableToken = new ethers.Contract(address, abi, wallet)
console.info(`Sending ${amountInWei} cUSD`)
const txResponse: providers.TransactionResponse = await stableToken.transferWithComment(recipient, amountInWei, comment)
const txReceipt = await txResponse.wait()
console.info(`cUSD payment hash received: ${txReceipt.transactionHash}`)

Alternative gas fee currencies

The Celo network supports paying for transactions with the native asset (CELO) but also with the stable token (cUSD).

This wrapper currently has partial support for specifying feeCurrency in transactions.

const gasPrice = await wallet.getGasPrice(stableTokenAddress)
const gasLimit = await wallet.estimateGas(tx)

// Gas estimation doesn't currently work properly for non-CELO currencies
// The gas limit must be padded to increase tx success rate
// TODO: Investigate more efficient ways to handle this case
const adjustedGasLimit = gasLimit.mul(10)

const txResponse = await signer.sendTransaction({
  ...tx,
  gasPrice,
  gasLimit: adjustedGasLimit,
  feeCurrency: stableTokenAddress,
})

Getting transaction history with CeloscanProvider

You can also rely on EthersProviders functionality, such as getting an account's transaction history, using our alternative CeloscanProvider

import { CeloscanProvider } from '@lj92458/celo-ethers-wrapper'

// You can use 'celo', 'alfajores' or 'baklava'.
// Default is 'celo' (mainnet)
const scanProvider = new CeloscanProvider('alfajores');

const history = await provider.getHistory(YOUR_ACCOUNT);
console.info("History:", history);

Examples

See the tests under /test for more detailed examples.