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

@makkii/app-eth

v0.1.2

Published

Ethereum application client implemented makkii-core.

Downloads

12

Readme

@makkii/app-eth

Ethereum application client.

This library uses some third-party service:

  • Web3 JsonRPC - you can pass in jsonrpc in EthApiClient Constructor
  • Explorer Api - To get transaction history, token history, we have two solutions:
    • http://api.ethplorer.io
    • http://api.etherscan.io/api
  • Transaction Explorer - To show transaction detail page:
    • https://www.etherchain.org/tx/<txHash>
    • https://api.etherscan.io/tx/<txHash>
  • Remote Api - we setup our own server to provide token list and icons.

Installation

$ npm install @makkii/app-eth

Usage

import { EthApiClient, EthKeystoreClient, EthLocalSigner } from '@makkii/app-eth';

const api_client = new EthApiClient({
    network: 'mainnet',
    jsonrpc: '***'
});
api_client.getBalance('0x...')
    .then(console.log)
    .catch(error=>console.log(error));
const keystore_client = new EthKeystoreClient();
api_client.buildTransaction(
    '0x...', // from address
    '0x...', // to address
    0, // amount
    {
        gasPrice: 10,
        gasLimit: 21000,
        isTokenTransfer: false
    }
).then(function(unsignedTx) {
    keystore_client.signTransaction(unsignedTx, new EthLocalSigner(), {
        private_key: '***'
    }).then(function(signedTx) {
        console.log(signedTx);
    });
});

API

Table of Contents

EthLocalSinger

Ethereum's signer using private key, implements IkeystoreSigner.

signTransaction

Sign transaction

Parameters
  • transaction EthUnsignedTx
  • params {private_key: string} parameters object, example: { private_key: '' }}
  • tx EthUnsignedTx transaction object to sign.

Returns Promise<string> transaction hash string

IEthConfig

Ethereum configuration interface

network

Network name

Type: ("mainnet" | "ropsten")

jsonrpc

JsonRPC endpoint

Type: string

explorer_api

api endpoint that used to query transaction information

Type: {provider: string, url: string, key: string}

explorer

Transaction explorer page

Type: {provider: string, url: string}

remote_api

app server endpoint that provides token, icons, etc.

Type: string

EthKeystoreClient

Ethereum keystore client that implements IsingleKeystoreClient

validatePrivateKey

throws not implemented error

Parameters

getAccountFromMnemonic

Get account from mnemonic

Parameters
  • address_index number index in hd wallet
  • mnemonic string mnemonic phrase

Returns any account object: { private_key: '', public_key: '', address: '', index: '' }

EthUnsignedTx

Ethereum unsigned transaction

  • to: string;
  • from: string;
  • nonce: string;
  • value: BigNumber;
  • gasPrice: number;
  • gasLimit: number;
  • data?: any;
  • network: string;

EthPendingTx

Ethereum pending transaction

  • hash: string;
  • status: "PENDING";
  • to: string;
  • from: string;
  • value: BigNumber;
  • tknTo?: string;
  • tknValue: BigNumber;
  • gasPrice: number;
  • gasLimit: number;

EthApiClient

Ethereum api client that implements IsingleApiFullClient

Parameters

getNetwork

Get network name: mainnet, amity.

getBlockByNumber

Get block by number, block information doesn't contains transaction details

Parameters
  • blockNumber string block number's hex string

Returns any eth_getBlockNumber response's result

getBlockNumber

Get latest block number

Returns any eth_getBlockNumber response's result

getTransactionStatus

Get transaction status.

Parameters

Returns Promise<any> if eth_getTransactionReceipt is null, returns null; else return object { status: true/false, blockNumber: intger, gasUsed: integer }

getTransactionsByAddress

Get transactions by the given address

Parameters

Returns any array of object structure which contains:- hash: string, with prefix 0x

  • timestamp: milli-seconds from 1970
  • from: sender
  • to: receiver
  • value: transfer amount
  • status: 'CONFIRMED' or 'FAILED'
  • blockNumber: hex string
  • fee: integer

sendTransaction

Send transaction

Parameters
  • unsignedTx EthUnsignedTx unsigned transaction build by buildTransaction
  • signer T localSigner or hardware
  • signerParams any localSigner: {private_key} hardware:{derivationIndex}

Returns Promise<EthPendingTx>

getTopTokens

Get top tokens

Parameters

Returns Promise<Array<Token>>