this fork is ment to provide updates
There are three methods of interest:
methodIDto create a function signature
rawEncodeto encode fields and
rawDecodeto decode fields
Planned for the future is supporting the JSON ABI definition:
This library also supports creating Solidity's tightly packed data constructs, which are used together with
ripemd160 to create hashes.
Creating the same hash using this library:
For the same data structure:
- sha3 will return
- sha256 will return
- ripemd160 will return
0x000000000000000000000000a398cc72490f72048efa52c4e92067e8499672e7(NOTE: it is 160bits, left padded to 256bits)
ripemd160() in Solidity returns bytes20 and if you cast it to bytes32, it will be right padded with zeroes.
Serpent uses a different notation for the types, even though it will serialize to the same ABI.
We provide two helpers to convert between these notations:
fromSerpent: convert a Serpent notation to the ABI notation
toSerpent: the other way around
It is to be used in conjunction with
Note: Serpent uses arbitary binary fields. If you want to store strings it is preferable to ensure it is stored as UTF8.
Buffer.from(<string>, 'utf8') can be used to ensure it is properly encoded.
I am more than happy to receive improvements. Please send me a pull request or reach out on email or twitter.
There is a lot missing, grep for FIXME in the source code to find inspiration.
See our organizational documentation for an introduction to
EthereumJS as well as information on current standards and best practices.
If you want to join for work or do improvements on the libraries have a look at our contribution guidelines.
Copyright (C) 2015 Alex Beregszaszi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.