_section: Fragments @ Explain an ABI. _subsection: Formats _heading: JSON String ABI (Solidity Output JSON) The **JSON ABI Format** is the format that is [output from the Solidity compiler](link-solc-output). A JSON serialized object is always a string, which represents an Array of Objects, where each Object has various properties describing the [[Fragment]] of the ABI. The deserialized JSON string (which is a normal JavaScript Object) may also be passed into any function which accepts a JSON String ABI. _heading: Humanb-Readable ABI @ The Human-Readable ABI was introduced by ethers in [this article](link-ricmoo-humanreadableabi) and has since gained wider adoption. The ABI is described by using an array of strings, where each string is the Solidity signature of the **constructor**, **function**, **event** or **error**. When parsing a fragment, all inferred properties will be injected (e.g. a //payable// method will have its ``constant`` proeprty set to false). Tuples can be specified by using the ``tuple(...)`` syntax or with bare (additional) parenthesis, ``(...)``. _code: Example Human-Readable ABI const ABI = [ // Constructor "constructor(address ens)", // Constant functions (pure or view) "function balanceOf(address owner) view returns (uint)", // State-mutating functions (payable or non-payable) "function mint(uint amount) payable", "function transfer(address to, uint amount) returns (bool)", // Events "event Transfer(address indexed from, address indexed to, uint amount)", // Errors "error InsufficientFunds(address from, uint balance)", ] _heading: Output Formats @ @SRC Each [[Fragment]] and [[ParamType]] may be output using its ``format`` method. _property: ethers.utils.FormatTypes.full => string This is a full human-readable string, including all parameter names, any optional modifiers (e.g. ``indexed``, ``public``, etc) and white-space to aid in human readability. _property: ethers.utils.FormatTypes.minimal => string This is similar to ``full``, except with no unnecessary whitespace or parameter names. This is useful for storing a minimal string which can still fully reconstruct the original Fragment using [Fragment . from](Fragment-from). _property: ethers.utils.FormatTypes.json => string This returns a JavaScript Object which is safe to call ``JSON.stringify`` on to create a JSON string. _property: ethers.utils.FormatTypes.sighash => string This is a minimal output format, which is used by Solidity when computing a signature hash or an event topic hash. _warning: Note The ``sighash`` format is **insufficient** to re-create the original [[Fragment]], since it discards modifiers such as indexed, anonymous, stateMutability, etc. It is only useful for computing the selector for a Fragment, and cannot be used to format an Interface. _subsection: Fragment @ @SRC An ABI is a collection of **Fragments**, where each fragment specifies: - An [Error](ErrorFragment) - An [Event](EventFragment) - A [Function](FunctionFragment) - A [Constructor](ConstructorFragment) _heading: Properties _property: fragment.name => string This is the name of the Event or Function. This will be null for a [[ConstructorFragment]]. _property: fragment.type => string This is a string which indicates the type of the [[Fragment]]. This will be one of: - ``constructor`` - ``event`` - ``function`` _property: fragment.inputs => Array<[[ParamType]]> This is an array of each [[ParamType]] for the input parameters to the Constructor, Event of Function. _heading: Methods _property: fragment.format([ format = sighash]) => string @ @SRC Creates a string representation of the Fragment using the available [output formats](fragments--output-formats). _property: ethers.utils.Fragment.from(objectOrString) => [[Fragment]] @ @SRC Creates a new **Fragment** sub-class from any compatible //objectOrString//. _property: ethers.utils.Fragment.isFragment(object) => boolean @ @SRC Returns true if //object// is a **Fragment**. _subsection: ConstructorFragment @ @INHERIT<[[Fragment]]> @SRC _heading: Properties _property: fragment.gas => [[BigNumber]] This is the gas limit that should be used during deployment. It may be null. _property: fragment.payable => boolean This is whether the constructor may receive ether during deployment as an endowment (i.e. msg.value != 0). _property: fragment.stateMutability => string This is the state mutability of the constructor. It can be any of: - ``nonpayable`` - ``payable`` _heading: Methods _property: ethers.utils.ConstructorFragment.from(objectOrString) => [[ConstructorFragment]] @ @SRC Creates a new **ConstructorFragment** from any compatible //objectOrString//. _property: ethers.utils.ConstructorFragment.isConstructorFragment(object) => boolean @ @SRC Returns true if //object// is a **ConstructorFragment**. _subsection: ErrorFragment @ @INHERIT<[[Fragment]]> @SRC _heading: Methods _property: ethers.utils.ErrorFragment.from(objectOrString) => [[ErrorFragment]] @ @SRC Creates a new **ErrorFragment** from any compatible //objectOrString//. _property: ethers.utils.ErrorFragment.isErrorFragment(object) => boolean @ @SRC Returns true if //object// is an **ErrorFragment**. _subsection: EventFragment @ @INHERIT<[[Fragment]]> @SRC _heading: Properties _property: fragment.anonymous => boolean This is whether the event is anonymous. An anonymous Event does not inject its topic hash as topic0 when creating a log. _heading: Methods _property: ethers.utils.EventFragment.from(objectOrString) => [[EventFragment]] @ @SRC Creates a new **EventFragment** from any compatible //objectOrString//. _property: ethers.utils.EventFragment.isEventFragment(object) => boolean @ @SRC Returns true if //object// is an **EventFragment**. _subsection: FunctionFragment @ @INHERIT<[[ConstructorFragment]]> @SRC _heading: Properties _property: fragment.constant => boolean This is whether the function is constant (i.e. does not change state). This is true if the state mutability is ``pure`` or ``view``. _property: fragment.stateMutability => string This is the state mutability of the constructor. It can be any of: - ``nonpayable`` - ``payable`` - ``pure`` - ``view`` _property: fragment.outputs => Array<[[ParamType]]> A list of the Function output parameters. _heading: Methods _property: ethers.utils.FunctionFragment.from(objectOrString) => [[FunctionFragment]] @ @SRC Creates a new **FunctionFragment** from any compatible //objectOrString//. _property: ethers.utils.FunctionFragment.isFunctionFragment(object) => boolean @ @SRC Returns true if //object// is a **FunctionFragment**. _subsection: ParamType @ @SRC The following examples will represent the Solidity parameter: ``string foobar`` _heading: Properties _property: paramType.name => string @ The local parameter name. This may be null for unnamed parameters. For example, the parameter definition ``string foobar`` would be ``foobar``. _property: paramType.type => string @ The full type of the parameter, including tuple and array symbols. This may be null for unnamed parameters. For the above example, this would be ``foobar``. _property: paramType.baseType => string @ The base type of the parameter. For primitive types (e.g. ``address``, ``uint256``, etc) this is equal to [type](ParamType-type). For arrays, it will be the string ``array`` and for a tuple, it will be the string ``tuple``. _property: paramType.indexed => boolean @ Whether the parameter has been marked as indexed. This **only** applies to parameters which are part of an [[EventFragment]]. _property: paramType.arrayChildren => [[ParamType]] @ The type of children of the array. This is null for any parameter which is not an array. _property: paramType.arrayLength => number @ The length of the array, or ``-1`` for dynamic-length arrays. This is null for parameters which are not arrays. _property: paramType.components => Array<[[ParamType]]> @ The components of a tuple. This is null for non-tuple parameters. _heading: Methods _property: paramType.format([ outputType = sighash ]) Creates a string representation of the Fragment using the available [output formats](fragments--output-formats). _property: ethers.utils.ParamType.from(objectOrString) => [[ParamType]] @ @SRC Creates a new **ParamType** from any compatible //objectOrString//. _property: ethers.utils.ParamType.isParamType(object) => boolean @ @SRC Returns true if //object// is a **ParamType**.