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

secjs-hashcode

v1.0.5

Published

Encoding for Contract Application Binary Interface (ABI), including function name and input paras, based on the rule https://solidity.readthedocs.io/en/develop/abi-spec.html

Downloads

9

Readme

secjs-hashcode

Encoding for Contract Application Binary Interface (ABI), including function name and input parameter values, based on the rule https://solidity.readthedocs.io/en/develop/abi-spec.html For further information in detail. Please refer to test cases and introduction in test/test.js.

JavaScript Style Guide

[JavaScript Style Guide]


new HashCode(sFnName, aParaValue)

new HashCode(sFnName, aParaValue) Constructs an Encoder.

| Param | Type | Description | | --- | --- | --- | | sFnName | String | The function name with the parenthesised list of parameter types. Parameter types are split by a single comma - no spaces are used. e.g. "sam(bytes,bool,uint[])"| | aParaValue | Array.<Dict> | The array of input Parameter Values with its type. e.g. [{value: 'dave', type: 'bytes'}, {value: true, type: 'bool'}, {value: [1, 2, 3], type: 'uint[]'}]|

Example

const HashCode = require('../src/index')

const sFnName = 'sam(bytes,bool,uint[])'
const aParaValue = [{value: 'dave', type: 'bytes'}, {value: true, type: 'bool'}, {value: [1, 2, 3], type: 'uint[]'}]
const oHashCode = new HashCode(sFnName, aParaValue)

HashCode.getFnName() ⇒ String

Returns the current Function Name information.

Example

const sFnName = oHashCode.getFnName()

HashCode.getParaValue() ⇒ Array.<Dict>

Returns the current input parameter values information.

Example

const aParaValue = oHashCode.getParaValue()

HashCode.setFnName(sFnName)

Set the Function Name.

Example

const sFnName = 'sam(bytes,bool,uint[])'
oHashCode.setFnName(sFnName)

HashCode.setParaValue(aParaValue)

Set the input parameter values.

Example

const aParaValue = [{value: 'dave', type: 'bytes'}, {value: true, type: 'bool'}, {value: [1, 2, 3], type: 'uint[]'}]
oHashCode.setParaValue(aParaValue)

HashCode.runHashCode()

Run the encoding based on current function name information and input parameter values

Example

oHashCode.runHashCode(aParaValue)

HashCode.getHashCode() ⇒ String

Returns the endcoded Bytecode String.

Example

const sByteCode = oHashCode1.getHashCode()
/*
An example for the format of result:
"8be6524600000000000000000000000000000000000000000000000000000000000001230000000000000000000000000000000000000000000000000000000000000080313233343536373839300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004560000000000000000000000000000000000000000000000000000000000000789000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000"
*/

HashCode.getHashCodeFragments() ⇒ Array.<String>

Returns the array of encoded result of each element to have a better look and check.

Example

const aHashCodeFragments = oHashCode1.getHashCodeFragments()
/*
An example for the format of result:
["8be65246",
"0000000000000000000000000000000000000000000000000000000000000123",
"0000000000000000000000000000000000000000000000000000000000000080",
"3132333435363738393000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000000000000000e0",
"0000000000000000000000000000000000000000000000000000000000000002",
"0000000000000000000000000000000000000000000000000000000000000456",
"0000000000000000000000000000000000000000000000000000000000000789",
"000000000000000000000000000000000000000000000000000000000000000d",
"48656c6c6f2c20776f726c642100000000000000000000000000000000000000"]
*/

HashCode.getHashCodeFragments() ⇒ Array.<String>

Show the encoded result of each element row by row in console to have a better look and check.

Example

oHashCode1.showHashCodeFragments()
/*
An example for the console output:
8be65246
0000000000000000000000000000000000000000000000000000000000000123
0000000000000000000000000000000000000000000000000000000000000080
3132333435363738393000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000e0
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000456
0000000000000000000000000000000000000000000000000000000000000789
000000000000000000000000000000000000000000000000000000000000000d
48656c6c6f2c20776f726c642100000000000000000000000000000000000000
*/