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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zkamoeba/micro-ethers

v6.0.2

Published

A Web3 library for interacting with the Micro Layer 2 scaling solution.

Downloads

5

Readme

🚀 micro-ethers JavaScript SDK 🚀

In order to provide easy access to all the features of micro, the micro-ethers JavaScript SDK was created, which is made in a way that has an interface very similar to those of ethers. In fact, ethers is a peer dependency of our library and most of the objects exported by micro-ethers ( e.g. Wallet, Provider etc.) inherit from the corresponding ethers objects and override only the fields that need to be changed.

While most of the existing SDKs should work out of the box, deploying smart contracts or using unique micro features, like account abstraction, requires providing additional fields to those that Ethereum transactions have by default.

The library is made in such a way that after replacing ethers with micro-ethers most client apps will work out of box.

📌 Overview

To begin, it is useful to have a basic understanding of the types of objects available and what they are responsible for, at a high level:

  • Provider provides connection to the micro blockchain, which allows querying the blockchain state, such as account, block or transaction details, querying event logs or evaluating read-only code using call. Additionally, the client facilitates writing to the blockchain by sending transactions.
  • Wallet wraps all operations that interact with an account. An account generally has a private key, which can be used to sign a variety of types of payloads. It provides easy usage of the most common features.

🛠 Prerequisites

📥 Installation & Setup

yarn add micro-ethers
yarn add ethers@6 # ethers is a peer dependency of micro-ethers

📝 Examples

The complete examples with various use cases are available here.

Connect to the micro network:

import { Provider, utils, types } from "micro-ethers";
import { ethers } from "ethers";

const provider = Provider.getDefaultProvider(types.Network.Goerli); // micro testnet (L2)
const ethProvider = ethers.getDefaultProvider("goerli"); // goerli testnet (L1)

Get the latest block number

const blockNumber = await provider.getBlockNumber();

Get the latest block

const block = await provider.getBlock("latest");

Create a wallet

const PRIVATE_KEY = process.env.PRIVATE_KEY;
const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider);

Check account balances

const ethBalance = await wallet.getBalance(); // balance on micro network

const ethBalanceL1 = await wallet.getBalanceL1(); // balance on goerli network

Transfer funds

Transfer funds among accounts on L2 network.

const receiver = Wallet.createRandom();

const transfer = await wallet.transfer({
    to: receiver,
    token: utils.ETH_ADDRESS,
    amount: ethers.parseEther("1.0"),
});

Deposit funds

Transfer funds from L1 to L2 network.

const deposit = await wallet.deposit({
    token: utils.ETH_ADDRESS,
    amount: ethers.parseEther("1.0"),
});

Withdraw funds

Transfer funds from L2 to L1 network.

const withdrawal = await wallet.withdraw({
    token: utils.ETH_ADDRESS,
    amount: ethers.parseEther("1.0"),
});

🤝 Contributing

We welcome contributions from the community! If you're interested in contributing to the micro-ethers JavaScript SDK, please take a look at our CONTRIBUTING.md for guidelines and details on the process.

Thank you for making micro-ethers JavaScript SDK better! 🙌