abi-coder.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * When sending values to or receiving values from a [[Contract]], the
  3. * data is generally encoded using the [ABI standard](link-solc-abi).
  4. *
  5. * The AbiCoder provides a utility to encode values to ABI data and
  6. * decode values from ABI data.
  7. *
  8. * Most of the time, developers should favour the [[Contract]] class,
  9. * which further abstracts a lot of the finer details of ABI data.
  10. *
  11. * @_section api/abi/abi-coder:ABI Encoding
  12. */
  13. import { Result } from "./coders/abstract-coder.js";
  14. import { ParamType } from "./fragments.js";
  15. import type { BytesLike, CallExceptionAction, CallExceptionError } from "../utils/index.js";
  16. /**
  17. * The **AbiCoder** is a low-level class responsible for encoding JavaScript
  18. * values into binary data and decoding binary data into JavaScript values.
  19. */
  20. export declare class AbiCoder {
  21. #private;
  22. /**
  23. * Get the default values for the given %%types%%.
  24. *
  25. * For example, a ``uint`` is by default ``0`` and ``bool``
  26. * is by default ``false``.
  27. */
  28. getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
  29. /**
  30. * Encode the %%values%% as the %%types%% into ABI data.
  31. *
  32. * @returns DataHexstring
  33. */
  34. encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
  35. /**
  36. * Decode the ABI %%data%% as the %%types%% into values.
  37. *
  38. * If %%loose%% decoding is enabled, then strict padding is
  39. * not enforced. Some older versions of Solidity incorrectly
  40. * padded event data emitted from ``external`` functions.
  41. */
  42. decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
  43. static _setDefaultMaxInflation(value: number): void;
  44. /**
  45. * Returns the shared singleton instance of a default [[AbiCoder]].
  46. *
  47. * On the first call, the instance is created internally.
  48. */
  49. static defaultAbiCoder(): AbiCoder;
  50. /**
  51. * Returns an ethers-compatible [[CallExceptionError]] Error for the given
  52. * result %%data%% for the [[CallExceptionAction]] %%action%% against
  53. * the Transaction %%tx%%.
  54. */
  55. static getBuiltinCallException(action: CallExceptionAction, tx: {
  56. to?: null | string;
  57. from?: null | string;
  58. data?: string;
  59. }, data: null | BytesLike): CallExceptionError;
  60. }
  61. //# sourceMappingURL=abi-coder.d.ts.map