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

jcc-ethereum-abi

v0.1.3

Published

Decoder and encoder for the ethereum ABI and decode events from ethereum transactions

Downloads

14

Readme

jcc-ethereum-abi

Decoder and encoder for the Ethereum ABI and decode events from Ethereum transactions.

npm Build Status Coverage Status Dependencies npm downloads PRs Welcome

Installtion

npm i jcc-ethereum-abi

API

APIs

How to use

See abi.spec.js for details.

参见abi.spec.js获得更多细节信息

jcc-ethereum-abi的作用是将合约调用演化为对函数名,参数的字符串拼接,类似call by name的方式对合约进行调用。这种方式极大的简化了对合约调用的封装工作。

const Web3 = require("web3");
const EthereumABI = require("jcc-ethereum-abi").EthereumABI;
const erc20ABI = require("./test/abi/erc20ABI");


// for encoding

// create contract instance
const web3 = new Web3(new Web3.providers.HttpProvider("https://localhost:8545"));
var myContract = new web3.eth.Contract(erc20ABI, '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe', {
    from: '0x1234567890123456789012345678901234567891', // default from address
    gasPrice: '20000000000' // default gas price in wei, 20 gwei in this case
});

const inst = new EthereumABI(myContract);
// encode
const data = EthereumABI.encode("transfer", "0x533243557dfdc87ae5bda885e22db00f87499971", "30000000000000000")


// for decoding data and transaction logs

// add abi to abiDecoder firstly
EthereumABI.addABI(erc20ABI);

// decode
const decode = EthereumABI.decode(data);

// decode transaction logs
const logs = [{
    data: "0x00000000000000000000000000000000000000000000017aedbc9d648c780000",
    address: "0x4c6007cea426e543551f2cb6392e6d6768f74706",
    blockHash: "0x181c92ab726131010021473d6e444d2f682e013eb12b2d4faa0946a8847c56f1",
    blockNumber: 3175749,
    logIndex: 0,
    removed: false,
    topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000687f6ab056708fcfd34b3226c0b70ddf95b2eab2", "0x00000000000000000000000066c9b619215db959ec137ede6b96f3fa6fd35a8a"],
    transactionHash: "0x9a7da10a30ad4c8e1bb4461107497130a19f53a844069dd3e019557ee1a423b8",
    transactionIndex: 1
}];
const decodeLogs = EthereumABI.decodeLogs(logs);


// remove ABIs and methodIDs from abiDecoder
EthereumABI.removeABI(erc20ABI);