🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

hardhat-prb-math

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

hardhat-prb-math

Hardhat plugin to complement PRBMath

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Hardhat PRBMath npm (scoped)

Hardhat plugin to complement the PRBMath smart contract library for advanced fixed-point math.

Description

This plugin is complementary to the PRBMath smart contract library for advanced fixed-point math. It provides mirroring TypeScript implementations for the mathematical functions originally written in Solidity.

Installation

First, install the plugin and its peer dependencies:

yarn add --dev hardhat-prb-math @ethersproject/bignumber evm-bn mathjs

Second, import the plugin in your hardhat.config.js:

require("hardhat-prb-math");

Or if you are using TypeScript, in your hardhat.config.ts:

import "hardhat-prb-math";

Tasks

This plugin adds no additional tasks.

Environment Extensions

This plugin extends the Hardhat Runtime Environment by adding a prb.math field whose type is HardhatPRBMath.

Configuration

This plugin does not extend the HardhatUserConfig object.

Usage

There are no additional steps you need to take for this plugin to work.

Install it and access prb.math through the Hardhat Runtime Environment anywhere you need it (tasks, scripts, tests, etc). For example, in your hardhat.config.ts:

import type { BigNumber } from "@ethersproject/bignumber";
import { fromBn, toBn } from "evm-bn";
import { task } from "hardhat/config";
import { TaskArguments } from "hardhat/types";

task("log2", "Calculate the binary logarithm")
  .addParam("x", "Input")
  .setAction(async function (taskArgs: TaskArguments, { prb }): Promise<void> {
    const x: BigNumber = toBn(taskArgs.x);
    const result: BigNumber = prb.math.log2(x);
    console.log({ result: fromBn(result) });
  });

export default {};

Tips

  • Read the documentation on the Hardhat Runtime Environment to learn how to access the HRE different ways.
  • Read the README in PRBMath to learn about all the functions available in the Solidity library.
  • See how this plugin is used in PRBMath.

License

Unlicense © Paul Razvan Berg

Keywords

blockchain

FAQs

Package last updated on 28 Sep 2021

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