@ocap/util
The @ocap/util package is a foundational library providing a collection of essential helper functions shared across multiple OCAP JS libraries. Designed to be isomorphic, it works seamlessly in both Node.js and browser environments. This module simplifies common tasks such as data type conversion, encoding/decoding, big number arithmetic, and bonding curve calculations, ensuring consistency and reliability in your applications.
Installation#
To get started, install the package using your preferred package manager:
Installation
pnpm install @ocap/utilKey Features#
@ocap/util provides a wide range of helpers to streamline your development process. Here are some of the core functionalities:
Data Conversion & Encoding
Seamlessly convert between various data formats like Hex, Buffers, and Uint8Arrays. Includes robust support for Base58 and Base64 encoding and decoding.
BigNumber & Token Math
Perform precise arithmetic with large integers using the integrated BN.js library. Easily convert between large units and human-readable token amounts.
Bonding Curve Calculations
A suite of functions for calculating token prices and costs based on different bonding curve models, including constant, linear, and quadratic curves.
DID & Address Helpers
Simplify Decentralized Identity management with helpers to convert between DID formats and wallet addresses, and to format transaction types.
API Reference#
For detailed usage and a complete list of all available functions, please refer to the comprehensive API Reference.