ethers.js/docs/v5/api/utils/abi/coder/README.md

40 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

2020-06-12 03:38:55 -04:00
-----
2020-07-03 01:54:56 -04:00
Documentation: [html](https://docs.ethers.io/)
2020-06-12 03:38:55 -04:00
-----
AbiCoder
========
Creating Instance
-----------------
#### **new ***ethers* . *utils* . **AbiCoder**( [ coerceFunc ] )
Create a new AbiCoder instance, which will call the *coerceFunc* on every decode, where the result of the call will be used in the Result.
The function signature is `(type, value)`, where the *type* is the string describing the type and the *value* is the processed value from the underlying Coder.
If the callback throws, the Result will contain a property that when accessed will throw, allowing for higher level libraries to recover from data errors.
#### *ethers* . *utils* . **defaultAbiCoder** => *[AbiCoder](/v5/api/utils/abi/coder/)*
An [AbiCoder](/v5/api/utils/abi/coder/) created when the library is imported which is used by the [Interface](/v5/api/utils/abi/interface/).
Coding Methods
--------------
#### *abiCoder* . **encode**( types , values ) => *string< [DataHexString](/v5/api/utils/bytes/#DataHexString) >*
2020-11-22 23:07:13 -05:00
Encode the array *values* according to the array of *types*, each of which may be a string or a [ParamType](/v5/api/utils/abi/fragments/#ParamType).
2020-06-12 03:38:55 -04:00
#### *abiCoder* . **decode**( types , data ) => *[Result](/v5/api/utils/abi/interface/#Result)*
Decode the *data* according to the array of *types*, each of which may be a string or [ParamType](/v5/api/utils/abi/fragments/#ParamType).