Skip to main content

format

Callable


  • Given data that can be interpreted according to the provided schema, returns equivalent data that has been formatted according to the provided return format.

    @example
    import { FMT_NUMBER, utils } from "web3";

    console.log(
    utils.format({ format: "uint" }, "221", { number: FMT_NUMBER.HEX }),
    );
    // 0xdd

    Type parameters

    Parameters

    • schema: ValidationSchemaInput | Schema

      how to interpret the data

    • data: DataType

      data to be formatted

    • returnFormat: ReturnType = ...

      how to format the data

    Returns FormatType<DataType, ReturnType>

    • formatted data