New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@rsksmart/rsk-utils

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rsksmart/rsk-utils

A collection of JS utility functions for Rootstock

  • 2.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

rsk-utils

A collection of JavaScript utility functions for Rootstock.

@rsksmart/rsk-utils is a library of utility functions designed to simplify working with the Rootstock blockchain ecosystem. It supports both CommonJS and ECMAScript Module (ESM) environments, making it versatile and easy to integrate into various projects.

Features

  • Supports CommonJS and ESM module systems.
  • Utility functions for working with addresses, bytes, and blockchain-specific operations.
  • TypeScript definitions included for better type safety.
  • Lightweight and easy to use.

Installation

Install the library via npm:

npm install @rsksmart/rsk-utils

Usage

CommonJS

For CommonJS environments:

const rskUtils = require('@rsksmart/rsk-utils');

// Example usage
const { toChecksumAddress } = rskUtils;
console.log(toChecksumAddress('0x27b1FdB04752bBc536007a920D24ACB045561c26', 30));

ESM

For ECMAScript Module (ESM) environments:

import { toChecksumAddress } from '@rsksmart/rsk-utils';

console.log(toChecksumAddress('0x27b1FdB04752bBc536007a920D24ACB045561c26', 30));

API Reference

Functions

toChecksumAddress(address: string, chainId: number | string): string

Generates a checksummed address according to EIP-1191.

  • Parameters:
    • address (string): The address to checksum.
    • chainId (number | string): The chain ID for the network.
  • Returns: A string representing the checksummed address.
isValidChecksumAddress(address: string, chainId: number | string): boolean

Validates whether an address has a correct checksum for a specific chain ID.

  • Parameters:
    • address (string): The address to validate.
    • chainId (number | string): The chain ID used for checksum validation.
  • Returns: true if the checksum is valid, false otherwise.
isAddress(address: string): boolean

Checks if a given string is a valid address.

  • Parameters:
    • address (string): The address to validate.
  • Returns: true if valid, false otherwise.

Testing

Run the test suite to ensure the library works as expected:

npm run test

This will execute unit tests and display the results.

Contributing

We welcome contributions to improve this library. Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Write clear commit messages and add tests for any changes.
  4. Submit a pull request with a detailed explanation of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

If you encounter any issues or have questions, feel free to open an issue on GitHub.

Keywords

FAQs

Package last updated on 13 Jan 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc