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.
[]
- HashCode
- new HashCode(sFnName, aParaValue)
- .getFnName() ⇒
String
- .getParaValue() ⇒
Array.<Dict>
- .setFnName(sFnName)
- .setParaValue(aParaValue)
- .runHashCode()
- .getHashCode() ⇒
String
- .getHashCodeFragments() ⇒
Array.<String>
- .showHashCodeFragments()
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 = const sFnName = 'sam(bytes,bool,uint[])'const aParaValue = value: 'dave' type: 'bytes' value: true type: 'bool' value: 1 2 3 type: 'uint[]'const oHashCode = sFnName aParaValue
String
HashCode.getFnName() ⇒ Returns the current Function Name information.
Example
const sFnName = oHashCode
Array.<Dict>
HashCode.getParaValue() ⇒ Returns the current input parameter values information.
Example
const aParaValue = oHashCode
HashCode.setFnName(sFnName)
Set the Function Name.
Example
const sFnName = 'sam(bytes,bool,uint[])'oHashCode
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
HashCode.runHashCode()
Run the encoding based on current function name information and input parameter values
Example
oHashCode
String
HashCode.getHashCode() ⇒ Returns the endcoded Bytecode String.
Example
const sByteCode = oHashCode1/*An example for the format of result:"8be6524600000000000000000000000000000000000000000000000000000000000001230000000000000000000000000000000000000000000000000000000000000080313233343536373839300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004560000000000000000000000000000000000000000000000000000000000000789000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000"*/
Array.<String>
HashCode.getHashCodeFragments() ⇒ Returns the array of encoded result of each element to have a better look and check.
Example
const aHashCodeFragments = oHashCode1/*An example for the format of result:["8be65246","0000000000000000000000000000000000000000000000000000000000000123","0000000000000000000000000000000000000000000000000000000000000080","3132333435363738393000000000000000000000000000000000000000000000","00000000000000000000000000000000000000000000000000000000000000e0","0000000000000000000000000000000000000000000000000000000000000002","0000000000000000000000000000000000000000000000000000000000000456","0000000000000000000000000000000000000000000000000000000000000789","000000000000000000000000000000000000000000000000000000000000000d","48656c6c6f2c20776f726c642100000000000000000000000000000000000000"]*/
Array.<String>
HashCode.getHashCodeFragments() ⇒ Show the encoded result of each element row by row in console to have a better look and check.
Example
oHashCode1/*An example for the console output:8be6524600000000000000000000000000000000000000000000000000000000000001230000000000000000000000000000000000000000000000000000000000000080313233343536373839300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004560000000000000000000000000000000000000000000000000000000000000789000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000*/