Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@restless/ethereum
Advanced tools
Readme
Ethereum module for restless. Uses ethers.js. Provides utilities such as:
npm install @restless/ethereum
yarn add @restless/ethereum
asEthAddress
Accepts any string that represents a valid ethereum address. Checks the checksum if present. Returns a normalized representation.
asEthAddress('0xA5fE...f213', 'path') // Result.ok(0xA5fE...f213)
asEthAddress('0xa5fe...f213', 'path') // Result.ok(0xA5fE...f213)
asEthAddress('bla bla bla', 'path') // Result.error([{expected: 'ethereum address', path: 'path'}])
asEthAddress(123, 'path') // Result.error([{expected: 'ethereum address', path: 'path'}])
asBigNumber
Accepts any string or number that represents an integer. Converts the integer to a BigNumber.
asBigNumber('123', 'path') // Result.ok(BigNumber(123))
asBigNumber(456, 'path') // Result.ok(BigNumber(456))
asBigNumber(1.5, 'path') // Result.error([{expected: 'big number', path: 'path'}])
asBigNumber(true, 'path') // Result.error([{expected: 'big number', path: 'path'}])
asHexBytes
Accepts any string that encodes binary data of specific length in hex format. The returned string is always lowercased.
const sanitizer = asHexBytes(3)
sanitizer('0x12ab56', 'path') // Result.ok('0x12ab56')
sanitizer('0x12AB56', 'path') // Result.ok('0x12ab56')
sanitizer('0x12AB5', 'path') // Result.error([{expected: 'hex string representing 3 bytes', path: 'path'}])
sanitizer(1234, 'path') // Result.error([{expected: 'hex string representing 3 bytes', path: 'path'}])
asTransactionHash
Accepts any string that can be a transaction hash.
const exampleHash = '0xd04b98f48e8f8bcc15c6ae5ac050801cd6dcfd428fb5f9e65c4e16e7807340fa'
asTransactionHash(exampleHash, 'path') // Result.ok('0xd04b...40fa')
asTransactionHash(exampleHash.toUpperCase(), 'path') // Result.ok('0xd04b...40fa')
sanitizer('0x12AB5', 'path') // Result.error([{expected: 'transaction hash', path: 'path'}])
sanitizer(1234, 'path') // Result.error([{expected: 'transaction hash', path: 'path'}])
FAQs
Ethereum utilities for restless
The npm package @restless/ethereum receives a total of 58 weekly downloads. As such, @restless/ethereum popularity was classified as not popular.
We found that @restless/ethereum demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.