contracts.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type {
  2. Provider, TransactionRequest, TransactionResponse
  3. } from "./provider.js";
  4. /**
  5. * A **ContractRunner** is a generic interface which defines an object
  6. * capable of interacting with a Contract on the network.
  7. *
  8. * The more operations supported, the more utility it is capable of.
  9. *
  10. * The most common ContractRunners are [Providers](Provider) which enable
  11. * read-only access and [Signers](Signer) which enable write-access.
  12. */
  13. export interface ContractRunner {
  14. /**
  15. * The provider used for necessary state querying operations.
  16. *
  17. * This can also point to the **ContractRunner** itself, in the
  18. * case of an [[AbstractProvider]].
  19. */
  20. provider: null | Provider;
  21. /**
  22. * Required to estimate gas.
  23. */
  24. estimateGas?: (tx: TransactionRequest) => Promise<bigint>;
  25. /**
  26. * Required for pure, view or static calls to contracts.
  27. */
  28. call?: (tx: TransactionRequest) => Promise<string>;
  29. /**
  30. * Required to support ENS names
  31. */
  32. resolveName?: (name: string) => Promise<null | string>;
  33. /**
  34. * Required for state mutating calls
  35. */
  36. sendTransaction?: (tx: TransactionRequest) => Promise<TransactionResponse>;
  37. }