mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-29 13:05:18 +02:00
abi-selectors
Contract ABI tooling: compute Ethereum function selectors.
Contract
src/selector.js is CommonJS and exports functionSelector(signature):
signatureis the canonical function signature string, e.g."transfer(address,uint256)"— no spaces, no argument names.- Returns
"0x"plus the first 4 bytes of the Keccak-256 hash of the UTF-8 signature, as 8 lowercase hex characters. - Throws
TypeErrorfor a non-string argument. - Node.js standard library only; no external dependencies. Whatever hashing you need, implement it in this repo.
- Run the tests with
npm test.
Note
Ethereum uses Keccak-256, the original Keccak submission, which predates the finalized NIST SHA3-256 standard. Mind that distinction.