August
  • 👋Introduction
  • 🎦Protocol Overview
  • 🪙Token & Tokenomics
  • Using August
    • 🚄TWAP
  • Smart Contracts
    • 🚥Risks and Audits
    • 🔗Contract Addresses
  • Developers
    • 📦Javascript SDK
      • 🤽Lending Pools
      • ⚡Utilities
      • 🔤Types
      • 📜ABI's
    • 🔮Subgraphs
  • Legal
    • 🗒️Legal
      • Terms of Service
      • Privacy Policy
      • Cookie Policy
  • Community
    • Home Page
    • X
Powered by GitBook
On this page
  • Installation
  • Featured Methods
  • Interacting with Contracts
  • Formatting
  • Datetime
  1. Developers
  2. Javascript SDK

Utilities

This package contains various utility methods to help you quickly bootstrap your blockchain-powered application.

PreviousLending PoolsNextTypes

Last updated 9 months ago

There are many utility methods exported from the utils package. We'll present a few examples of the more commonly used utility and useful methods, but take a look at the .

Installation

Install the package in your project directory with:

npm install @augustdigital/utils

You can import individual methods and constants from the utilities package with the following:

import { <METHOD> } from '@augustdigital/utils';

or the CommonJS way:

const augustUtils from '@augustdigital/utils';

Featured Methods

Interacting with Contracts

Simulate Transaction

To see the final result of a read or write smart contract method without writing to the blockchain.

async function simulateTransaction(
  infura: IInfuraOptions,
  abi: string[] | any,
  functionName: string,
  options?: {
    args?: (string | number | bigint)[][];
    from?: string;
    to?: string;
  },
): ContractResult<any>

Formatting

Normalize Value

Formats any number type to an object containing the string value as well as the big number value.

function toNormalizedBn(
  value: string | bigint | number,
  decimals: number = 18,
): INormalizedNumber {
  raw: bigint;
  normalized: string;
}

Datetime

UNIX Timestamp to Date

function unixToDate(epoch: number): Date

Get Date X Days Ago

Quickly get new past date by inputting the amount of days from today.

export function daysAgo(days: number): Date

Formats number type to a Date to assist in displaying on your UI. Especially useful when working with .

📦
⚡
our subgraphs
entire API here
Logonpm: @augustdigital/utilsnpm