diff --git a/docs.wrm/api/contract/example.wrm b/docs.wrm/api/contract/example.wrm index 34e0e224f2..32cf2c4cae 100644 --- a/docs.wrm/api/contract/example.wrm +++ b/docs.wrm/api/contract/example.wrm @@ -2,7 +2,43 @@ _section: Example: ERC-20 Contract _subsection: Connecting to a Contract -_code: token.txt +_code: A simple ERC-20 contract @lang + +// A Human-Readable ABI; any supported ABI format could be used +const abi = [ + // Read-Only Functions + "function balanceOf(address owner) view returns (uint256)", + "function decimals() view returns (uint8)", + "function symbol() view returns (string)", + + // Authenticated Functions + "function transfer(address to, uint amount) returns (boolean)", + + // Events + "event Transfer(address indexed from, address indexed to, uint amount)" +]; + +// This can be an address or an ENS name +const address = "dai.tokens.ethers.eth"; + +// An example Provider +const provider = ethers.getDefaultProvider(); + +// An example Signer +const signer = ethers.Wallet.createRandom().connect(provider); + +// Read-Only; By connecting to a Provider, allows: +// - Any constant function +// - Querying Filters +// - Populating Unsigned Transactions for non-constant methods +// - Estimating Gas for non-constant (as an anonymous sender) +// - Static Calling non-constant methods (as anonymous sender) +const erc20 = new ethers.Contract(address, abi, provider); + +// Read-Write; By connecting to a Signer, allows: +// - Everything from Read-Only (except as Signer, not anonymous) +// - Sending transactions for non-constant functions +const erc20_rw = new ethers.Contract(address, abi, signer) _heading: ERC20Contract @INHERIT<[[contract]]> diff --git a/docs.wrm/api/providers/provider.wrm b/docs.wrm/api/providers/provider.wrm index e078a0e759..4d9eea0948 100644 --- a/docs.wrm/api/providers/provider.wrm +++ b/docs.wrm/api/providers/provider.wrm @@ -22,7 +22,27 @@ sent to the network. _heading: Examples -_code: example-account.js +_code: @lang + +// +const provider = ethers.getDefaultProvider() +// + +// Get the balance for an account... +provider.getBalance("ricmoo.firefly.eth"); +//! + +// Get the code for a contract... +provider.getCode("registrar.firefly.eth"); +//! + +// Get the storage value at position 0... +provider.getStorageAt("registrar.firefly.eth", 0) +//! + +// Get transaction count of an account... +provider.getTransactionCount("ricmoo.firefly.eth"); +//! _subsection: Blocks Methods @@ -52,7 +72,20 @@ not have an address configured, ``null`` is returned. _heading: Examples -_code: example-ens.js +_code: @lang + +// +const provider = ethers.getDefaultProvider() +// + +// Reverse lookup of an ENS by address... +provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c"); +//! + +// Lookup an address of an ENS name... +provider.resolveName("ricmoo.firefly.eth"); +//! + _subsection: Logs Methods diff --git a/docs.wrm/api/providers/types.wrm b/docs.wrm/api/providers/types.wrm index 9179460f9b..014a17765a 100644 --- a/docs.wrm/api/providers/types.wrm +++ b/docs.wrm/api/providers/types.wrm @@ -240,7 +240,7 @@ If this transaction has a ``null`` to address, it is an **init transaction** used to deploy a contract, in which case this is the address created by that contract. -To compute a contract address, the [getContractAddress](utils-getcontractaddress) +To compute a contract address, the [getContractAddress](utils-getContractAddress) utility function can also be used with a [[provider-transactionresponse]] object, which requires the transaction nonce and the address of the sender. diff --git a/docs.wrm/api/utils/address.wrm b/docs.wrm/api/utils/address.wrm index a2392e1e31..15597b030e 100644 --- a/docs.wrm/api/utils/address.wrm +++ b/docs.wrm/api/utils/address.wrm @@ -39,7 +39,7 @@ accepts an address can receive an ICAP address, and it will be converted interna To convert an address into the ICAP format, see [getIcapAddress](utils-getIcapAddress). -_subsection: Functions +_subsection: Converting and Verifying @ _property: ethers.utils.getAddress(address) => string<[[address]]> @ @SRC
Returns //address// as a Checksum Address. @@ -49,18 +49,35 @@ the checksum is invalid, an InvalidArgument Error is throw. The value of //address// may be any supported address format. +_property: ethers.utils.getIcapAddress(address) => string<[IcapAddress](address-icap)> @ @SRC
+Returns //address// as an [ICAP address](link-icap). +Supports the same restrictions as [utils.getAddress](utils-getAddress). _property: ethers.utils.isAddress(address) => boolean @ @SRC
Returns true if //address// is valid (in any supported format). -_property: ethers.utils.getIcapAddress(address) => string<[IcapAddress](address-icap)> @ @SRC
-Returns //address// as an [ICAP address](link-icap). -Supports the same restrictions as [utils.getAddress](utils-getAddress). -_property: ethers.utils.getContractAddress(transaction) => string<[[address]]> @ @SRC
+_subsection: Derivation @ + +_property: ethers.utils.computeAddress(publicOrPrivateKey) => string<[[address]]> @ @SRC +Returns the address for //publicOrPrivateKey//. A public key may be +compressed or uncompressed, and a private key will be converted +automatically to a public key for the derivation. + +_property: ethers.utils.recoverAddress(digest, signature) => string<[[address]]> @ @SRC +Use [[link-wiki-ecrecover]] to determine the address that signed //digest// to +which generated //signature//. + + +_subsection: Contracts Addresses @ + +_property: ethers.utils.getContractAddress(transaction) => string<[[address]]> @ @SRC
Returns the contract address that would result if //transaction// was used to deploy a contract. _property: ethers.utils.getCreate2Address(from, salt, initCodeHash) => string<[[address]]> @ @SRC
Returns the contract address that would result from the given [CREATE2](link-eip-1014) call. + + + diff --git a/docs.wrm/api/utils/bignumber.wrm b/docs.wrm/api/utils/bignumber.wrm index 6dea83e44e..698950a1af 100644 --- a/docs.wrm/api/utils/bignumber.wrm +++ b/docs.wrm/api/utils/bignumber.wrm @@ -13,7 +13,23 @@ and parameters which accept values will generally accept them. _heading: Importing -_code: bignumber-import.source +_code: CommonJS @lang diff --git a/docs.wrm/migration/ethers-v4/index.wrm b/docs.wrm/migration/ethers-v4/index.wrm index 9757db05a4..faaa84dd68 100644 --- a/docs.wrm/migration/ethers-v4/index.wrm +++ b/docs.wrm/migration/ethers-v4/index.wrm @@ -5,18 +5,42 @@ _subsection: BigNumber _heading: Namespace Since [[bignumber]] is used quite frequently, it has been moved to the top level of the umbrella package. -_code: bignumber-namespace.txt + +_code: @lang