viem 0.3.0-tsc-nodenext-2.20230407T050527 → 0.4.0-main.20230412T020839
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/accounts/generateMnemonic.js +0 -7
- package/dist/cjs/accounts/generateMnemonic.js.map +1 -1
- package/dist/cjs/accounts/generatePrivateKey.js +0 -5
- package/dist/cjs/accounts/generatePrivateKey.js.map +1 -1
- package/dist/cjs/accounts/hdKeyToAccount.js +0 -5
- package/dist/cjs/accounts/hdKeyToAccount.js.map +1 -1
- package/dist/cjs/accounts/mnemonicToAccount.js +0 -5
- package/dist/cjs/accounts/mnemonicToAccount.js.map +1 -1
- package/dist/cjs/accounts/privateKeyToAccount.js +0 -5
- package/dist/cjs/accounts/privateKeyToAccount.js.map +1 -1
- package/dist/cjs/accounts/toAccount.js +0 -5
- package/dist/cjs/accounts/toAccount.js.map +1 -1
- package/dist/cjs/accounts/utils/publicKeyToAddress.js +0 -7
- package/dist/cjs/accounts/utils/publicKeyToAddress.js.map +1 -1
- package/dist/cjs/accounts/utils/sign.js +0 -8
- package/dist/cjs/accounts/utils/sign.js.map +1 -1
- package/dist/cjs/accounts/utils/signMessage.js +0 -6
- package/dist/cjs/accounts/utils/signMessage.js.map +1 -1
- package/dist/cjs/accounts/utils/signTypedData.js +0 -6
- package/dist/cjs/accounts/utils/signTypedData.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsAddress.js +0 -6
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsAvatar.js +0 -3
- package/dist/cjs/actions/ens/getEnsAvatar.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsName.js +0 -12
- package/dist/cjs/actions/ens/getEnsName.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsResolver.js +0 -3
- package/dist/cjs/actions/ens/getEnsResolver.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsText.js +0 -15
- package/dist/cjs/actions/ens/getEnsText.js.map +1 -1
- package/dist/cjs/actions/getContract.js +0 -14
- package/dist/cjs/actions/getContract.js.map +1 -1
- package/dist/cjs/actions/public/call.js +0 -1
- package/dist/cjs/actions/public/call.js.map +1 -1
- package/dist/cjs/actions/public/createBlockFilter.js +5 -1
- package/dist/cjs/actions/public/createBlockFilter.js.map +1 -1
- package/dist/cjs/actions/public/createContractEventFilter.js +5 -0
- package/dist/cjs/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/createEventFilter.js +5 -0
- package/dist/cjs/actions/public/createEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/createPendingTransactionFilter.js +5 -1
- package/dist/cjs/actions/public/createPendingTransactionFilter.js.map +1 -1
- package/dist/cjs/actions/public/estimateContractGas.js.map +1 -1
- package/dist/cjs/actions/public/estimateGas.js +0 -4
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/public/getBalance.js +0 -3
- package/dist/cjs/actions/public/getBalance.js.map +1 -1
- package/dist/cjs/actions/public/getBlock.js.map +1 -1
- package/dist/cjs/actions/public/getBlockNumber.js +0 -3
- package/dist/cjs/actions/public/getBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/getBlockTransactionCount.js.map +1 -1
- package/dist/cjs/actions/public/getBytecode.js.map +1 -1
- package/dist/cjs/actions/public/getChainId.js.map +1 -1
- package/dist/cjs/actions/public/getFeeHistory.js +0 -3
- package/dist/cjs/actions/public/getFeeHistory.js.map +1 -1
- package/dist/cjs/actions/public/getFilterChanges.js +2 -3
- package/dist/cjs/actions/public/getFilterChanges.js.map +1 -1
- package/dist/cjs/actions/public/getFilterLogs.js +2 -3
- package/dist/cjs/actions/public/getFilterLogs.js.map +1 -1
- package/dist/cjs/actions/public/getGasPrice.js +0 -3
- package/dist/cjs/actions/public/getGasPrice.js.map +1 -1
- package/dist/cjs/actions/public/getLogs.js +0 -4
- package/dist/cjs/actions/public/getLogs.js.map +1 -1
- package/dist/cjs/actions/public/getStorageAt.js.map +1 -1
- package/dist/cjs/actions/public/getTransaction.js +0 -1
- package/dist/cjs/actions/public/getTransaction.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionCount.js +0 -3
- package/dist/cjs/actions/public/getTransactionCount.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/multicall.js +0 -1
- package/dist/cjs/actions/public/multicall.js.map +1 -1
- package/dist/cjs/actions/public/readContract.js.map +1 -1
- package/dist/cjs/actions/public/simulateContract.js.map +1 -1
- package/dist/cjs/actions/public/uninstallFilter.js +2 -2
- package/dist/cjs/actions/public/uninstallFilter.js.map +1 -1
- package/dist/cjs/actions/public/waitForTransactionReceipt.js +0 -11
- package/dist/cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/watchBlockNumber.js +0 -7
- package/dist/cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/watchBlocks.js +1 -13
- package/dist/cjs/actions/public/watchBlocks.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +0 -6
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +0 -6
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/cjs/actions/wallet/deployContract.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js +0 -2
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/signTypedData.js +0 -2
- package/dist/cjs/actions/wallet/signTypedData.js.map +1 -1
- package/dist/cjs/adapters/ethers.js +0 -5
- package/dist/cjs/adapters/ethers.js.map +1 -1
- package/dist/cjs/clients/createClient.js +0 -3
- package/dist/cjs/clients/createClient.js.map +1 -1
- package/dist/cjs/clients/createPublicClient.js +0 -3
- package/dist/cjs/clients/createPublicClient.js.map +1 -1
- package/dist/cjs/clients/createTestClient.js +0 -3
- package/dist/cjs/clients/createTestClient.js.map +1 -1
- package/dist/cjs/clients/createWalletClient.js +0 -3
- package/dist/cjs/clients/createWalletClient.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/clients/decorators/wallet.js.map +1 -1
- package/dist/cjs/clients/transports/createTransport.js +0 -3
- package/dist/cjs/clients/transports/createTransport.js.map +1 -1
- package/dist/cjs/clients/transports/custom.js +0 -3
- package/dist/cjs/clients/transports/custom.js.map +1 -1
- package/dist/cjs/clients/transports/fallback.js +18 -12
- package/dist/cjs/clients/transports/fallback.js.map +1 -1
- package/dist/cjs/clients/transports/http.js +1 -6
- package/dist/cjs/clients/transports/http.js.map +1 -1
- package/dist/cjs/clients/transports/webSocket.js +1 -6
- package/dist/cjs/clients/transports/webSocket.js.map +1 -1
- package/dist/cjs/constants/abis.js +0 -1
- package/dist/cjs/constants/abis.js.map +1 -1
- package/dist/cjs/constants/solidity.js +0 -1
- package/dist/cjs/constants/solidity.js.map +1 -1
- package/dist/cjs/errors/abi.js.map +1 -1
- package/dist/cjs/errors/account.js.map +1 -1
- package/dist/cjs/errors/address.js.map +1 -1
- package/dist/cjs/errors/base.js +27 -21
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/block.js.map +1 -1
- package/dist/cjs/errors/chain.js.map +1 -1
- package/dist/cjs/errors/contract.js.map +1 -1
- package/dist/cjs/errors/data.js.map +1 -1
- package/dist/cjs/errors/encoding.js.map +1 -1
- package/dist/cjs/errors/ens.js.map +1 -1
- package/dist/cjs/errors/estimateGas.js.map +1 -1
- package/dist/cjs/errors/index.js +27 -23
- package/dist/cjs/errors/index.js.map +1 -1
- package/dist/cjs/errors/log.js.map +1 -1
- package/dist/cjs/errors/node.js +0 -9
- package/dist/cjs/errors/node.js.map +1 -1
- package/dist/cjs/errors/request.js +50 -259
- package/dist/cjs/errors/request.js.map +1 -1
- package/dist/cjs/errors/rpc.js +271 -50
- package/dist/cjs/errors/rpc.js.map +1 -1
- package/dist/cjs/errors/transaction.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/errors/version.js.map +1 -1
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/eip1193.js +0 -2
- package/dist/cjs/types/eip1193.js.map +1 -1
- package/dist/cjs/utils/abi/decodeAbiParameters.js +0 -29
- package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/decodeEventLog.js +0 -2
- package/dist/cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/cjs/utils/abi/encodeAbiParameters.js +1 -10
- package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/getAbiItem.js +0 -7
- package/dist/cjs/utils/abi/getAbiItem.js.map +1 -1
- package/dist/cjs/utils/accounts.js +0 -3
- package/dist/cjs/utils/accounts.js.map +1 -1
- package/dist/cjs/utils/buildRequest.js +16 -3
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/cjs/utils/data/size.js +0 -6
- package/dist/cjs/utils/data/size.js.map +1 -1
- package/dist/cjs/utils/data/slice.js +0 -21
- package/dist/cjs/utils/data/slice.js.map +1 -1
- package/dist/cjs/utils/encoding/fromBytes.js +0 -15
- package/dist/cjs/utils/encoding/fromBytes.js.map +1 -1
- package/dist/cjs/utils/encoding/fromHex.js +0 -15
- package/dist/cjs/utils/encoding/fromHex.js.map +1 -1
- package/dist/cjs/utils/encoding/toBytes.js +0 -13
- package/dist/cjs/utils/encoding/toBytes.js.map +1 -1
- package/dist/cjs/utils/encoding/toHex.js +0 -15
- package/dist/cjs/utils/encoding/toHex.js.map +1 -1
- package/dist/cjs/utils/ens/avatar/parseAvatarRecord.js +2 -6
- package/dist/cjs/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/dist/cjs/utils/ens/avatar/utils.js +0 -10
- package/dist/cjs/utils/ens/avatar/utils.js.map +1 -1
- package/dist/cjs/utils/ens/labelhash.js +0 -9
- package/dist/cjs/utils/ens/labelhash.js.map +1 -1
- package/dist/cjs/utils/ens/namehash.js +0 -12
- package/dist/cjs/utils/ens/namehash.js.map +1 -1
- package/dist/cjs/utils/ens/normalize.js +0 -10
- package/dist/cjs/utils/ens/normalize.js.map +1 -1
- package/dist/cjs/utils/ens/packetToBytes.js +0 -4
- package/dist/cjs/utils/ens/packetToBytes.js.map +1 -1
- package/dist/cjs/utils/errors/getNodeError.js +28 -27
- package/dist/cjs/utils/errors/getNodeError.js.map +1 -1
- package/dist/cjs/utils/filters/createFilterRequestScope.js +14 -0
- package/dist/cjs/utils/filters/createFilterRequestScope.js.map +1 -0
- package/dist/cjs/utils/formatters/block.js +0 -1
- package/dist/cjs/utils/formatters/block.js.map +1 -1
- package/dist/cjs/utils/formatters/extract.js +0 -3
- package/dist/cjs/utils/formatters/extract.js.map +1 -1
- package/dist/cjs/utils/formatters/format.js +0 -3
- package/dist/cjs/utils/formatters/format.js.map +1 -1
- package/dist/cjs/utils/observe.js +0 -5
- package/dist/cjs/utils/observe.js.map +1 -1
- package/dist/cjs/utils/poll.js +0 -3
- package/dist/cjs/utils/poll.js.map +1 -1
- package/dist/cjs/utils/promise/withCache.js +0 -13
- package/dist/cjs/utils/promise/withCache.js.map +1 -1
- package/dist/cjs/utils/regex.js +0 -4
- package/dist/cjs/utils/regex.js.map +1 -1
- package/dist/cjs/utils/rpc.js +3 -13
- package/dist/cjs/utils/rpc.js.map +1 -1
- package/dist/cjs/utils/signature/hashTypedData.js +0 -3
- package/dist/cjs/utils/signature/hashTypedData.js.map +1 -1
- package/dist/cjs/utils/signature/recoverAddress.js +0 -2
- package/dist/cjs/utils/signature/recoverAddress.js.map +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js +0 -4
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/cjs/utils/transaction/serializeTransaction.js +2 -4
- package/dist/cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/cjs/utils/typedData.js +0 -4
- package/dist/cjs/utils/typedData.js.map +1 -1
- package/dist/cjs/utils/unit/parseUnits.js +0 -2
- package/dist/cjs/utils/unit/parseUnits.js.map +1 -1
- package/dist/esm/accounts/generateMnemonic.js +0 -7
- package/dist/esm/accounts/generateMnemonic.js.map +1 -1
- package/dist/esm/accounts/generatePrivateKey.js +0 -5
- package/dist/esm/accounts/generatePrivateKey.js.map +1 -1
- package/dist/esm/accounts/hdKeyToAccount.js +0 -5
- package/dist/esm/accounts/hdKeyToAccount.js.map +1 -1
- package/dist/esm/accounts/mnemonicToAccount.js +0 -5
- package/dist/esm/accounts/mnemonicToAccount.js.map +1 -1
- package/dist/esm/accounts/privateKeyToAccount.js +0 -5
- package/dist/esm/accounts/privateKeyToAccount.js.map +1 -1
- package/dist/esm/accounts/toAccount.js +0 -5
- package/dist/esm/accounts/toAccount.js.map +1 -1
- package/dist/esm/accounts/utils/publicKeyToAddress.js +0 -7
- package/dist/esm/accounts/utils/publicKeyToAddress.js.map +1 -1
- package/dist/esm/accounts/utils/sign.js +0 -8
- package/dist/esm/accounts/utils/sign.js.map +1 -1
- package/dist/esm/accounts/utils/signMessage.js +0 -6
- package/dist/esm/accounts/utils/signMessage.js.map +1 -1
- package/dist/esm/accounts/utils/signTypedData.js +0 -6
- package/dist/esm/accounts/utils/signTypedData.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js +0 -6
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAvatar.js +0 -3
- package/dist/esm/actions/ens/getEnsAvatar.js.map +1 -1
- package/dist/esm/actions/ens/getEnsName.js +0 -12
- package/dist/esm/actions/ens/getEnsName.js.map +1 -1
- package/dist/esm/actions/ens/getEnsResolver.js +0 -3
- package/dist/esm/actions/ens/getEnsResolver.js.map +1 -1
- package/dist/esm/actions/ens/getEnsText.js +0 -15
- package/dist/esm/actions/ens/getEnsText.js.map +1 -1
- package/dist/esm/actions/getContract.js +0 -14
- package/dist/esm/actions/getContract.js.map +1 -1
- package/dist/esm/actions/public/call.js +0 -1
- package/dist/esm/actions/public/call.js.map +1 -1
- package/dist/esm/actions/public/createBlockFilter.js +5 -1
- package/dist/esm/actions/public/createBlockFilter.js.map +1 -1
- package/dist/esm/actions/public/createContractEventFilter.js +5 -0
- package/dist/esm/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createEventFilter.js +5 -0
- package/dist/esm/actions/public/createEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createPendingTransactionFilter.js +5 -1
- package/dist/esm/actions/public/createPendingTransactionFilter.js.map +1 -1
- package/dist/esm/actions/public/estimateContractGas.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +0 -4
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/getBalance.js +0 -3
- package/dist/esm/actions/public/getBalance.js.map +1 -1
- package/dist/esm/actions/public/getBlock.js.map +1 -1
- package/dist/esm/actions/public/getBlockNumber.js +0 -3
- package/dist/esm/actions/public/getBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/getBlockTransactionCount.js.map +1 -1
- package/dist/esm/actions/public/getBytecode.js.map +1 -1
- package/dist/esm/actions/public/getChainId.js.map +1 -1
- package/dist/esm/actions/public/getFeeHistory.js +0 -3
- package/dist/esm/actions/public/getFeeHistory.js.map +1 -1
- package/dist/esm/actions/public/getFilterChanges.js +2 -3
- package/dist/esm/actions/public/getFilterChanges.js.map +1 -1
- package/dist/esm/actions/public/getFilterLogs.js +2 -3
- package/dist/esm/actions/public/getFilterLogs.js.map +1 -1
- package/dist/esm/actions/public/getGasPrice.js +0 -3
- package/dist/esm/actions/public/getGasPrice.js.map +1 -1
- package/dist/esm/actions/public/getLogs.js +0 -4
- package/dist/esm/actions/public/getLogs.js.map +1 -1
- package/dist/esm/actions/public/getStorageAt.js.map +1 -1
- package/dist/esm/actions/public/getTransaction.js +0 -1
- package/dist/esm/actions/public/getTransaction.js.map +1 -1
- package/dist/esm/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/esm/actions/public/getTransactionCount.js +0 -3
- package/dist/esm/actions/public/getTransactionCount.js.map +1 -1
- package/dist/esm/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/multicall.js +0 -1
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/actions/public/readContract.js.map +1 -1
- package/dist/esm/actions/public/simulateContract.js.map +1 -1
- package/dist/esm/actions/public/uninstallFilter.js +2 -2
- package/dist/esm/actions/public/uninstallFilter.js.map +1 -1
- package/dist/esm/actions/public/waitForTransactionReceipt.js +0 -11
- package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js +0 -7
- package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js +1 -13
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +0 -6
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +0 -6
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/esm/actions/wallet/deployContract.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js +0 -2
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/signTypedData.js +0 -2
- package/dist/esm/actions/wallet/signTypedData.js.map +1 -1
- package/dist/esm/adapters/ethers.js +0 -5
- package/dist/esm/adapters/ethers.js.map +1 -1
- package/dist/esm/clients/createClient.js +0 -3
- package/dist/esm/clients/createClient.js.map +1 -1
- package/dist/esm/clients/createPublicClient.js +0 -3
- package/dist/esm/clients/createPublicClient.js.map +1 -1
- package/dist/esm/clients/createTestClient.js +0 -3
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/createWalletClient.js +0 -3
- package/dist/esm/clients/createWalletClient.js.map +1 -1
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/clients/decorators/wallet.js.map +1 -1
- package/dist/esm/clients/transports/createTransport.js +0 -3
- package/dist/esm/clients/transports/createTransport.js.map +1 -1
- package/dist/esm/clients/transports/custom.js +0 -3
- package/dist/esm/clients/transports/custom.js.map +1 -1
- package/dist/esm/clients/transports/fallback.js +18 -12
- package/dist/esm/clients/transports/fallback.js.map +1 -1
- package/dist/esm/clients/transports/http.js +1 -6
- package/dist/esm/clients/transports/http.js.map +1 -1
- package/dist/esm/clients/transports/webSocket.js +1 -6
- package/dist/esm/clients/transports/webSocket.js.map +1 -1
- package/dist/esm/constants/abis.js +0 -1
- package/dist/esm/constants/abis.js.map +1 -1
- package/dist/esm/constants/solidity.js +0 -1
- package/dist/esm/constants/solidity.js.map +1 -1
- package/dist/esm/errors/abi.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/address.js.map +1 -1
- package/dist/esm/errors/base.js +27 -21
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/block.js.map +1 -1
- package/dist/esm/errors/chain.js.map +1 -1
- package/dist/esm/errors/contract.js.map +1 -1
- package/dist/esm/errors/data.js.map +1 -1
- package/dist/esm/errors/encoding.js.map +1 -1
- package/dist/esm/errors/ens.js.map +1 -1
- package/dist/esm/errors/estimateGas.js.map +1 -1
- package/dist/esm/errors/index.js +4 -4
- package/dist/esm/errors/index.js.map +1 -1
- package/dist/esm/errors/log.js.map +1 -1
- package/dist/esm/errors/node.js +0 -9
- package/dist/esm/errors/node.js.map +1 -1
- package/dist/esm/errors/request.js +45 -241
- package/dist/esm/errors/request.js.map +1 -1
- package/dist/esm/errors/rpc.js +249 -45
- package/dist/esm/errors/rpc.js.map +1 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/errors/version.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/eip1193.js +0 -2
- package/dist/esm/types/eip1193.js.map +1 -1
- package/dist/esm/utils/abi/decodeAbiParameters.js +0 -29
- package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/decodeEventLog.js +0 -2
- package/dist/esm/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js +1 -10
- package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/getAbiItem.js +0 -7
- package/dist/esm/utils/abi/getAbiItem.js.map +1 -1
- package/dist/esm/utils/accounts.js +0 -3
- package/dist/esm/utils/accounts.js.map +1 -1
- package/dist/esm/utils/buildRequest.js +16 -3
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/data/size.js +0 -6
- package/dist/esm/utils/data/size.js.map +1 -1
- package/dist/esm/utils/data/slice.js +0 -21
- package/dist/esm/utils/data/slice.js.map +1 -1
- package/dist/esm/utils/encoding/fromBytes.js +0 -15
- package/dist/esm/utils/encoding/fromBytes.js.map +1 -1
- package/dist/esm/utils/encoding/fromHex.js +0 -15
- package/dist/esm/utils/encoding/fromHex.js.map +1 -1
- package/dist/esm/utils/encoding/toBytes.js +0 -13
- package/dist/esm/utils/encoding/toBytes.js.map +1 -1
- package/dist/esm/utils/encoding/toHex.js +0 -15
- package/dist/esm/utils/encoding/toHex.js.map +1 -1
- package/dist/esm/utils/ens/avatar/parseAvatarRecord.js +2 -6
- package/dist/esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/dist/esm/utils/ens/avatar/utils.js +0 -10
- package/dist/esm/utils/ens/avatar/utils.js.map +1 -1
- package/dist/esm/utils/ens/labelhash.js +0 -9
- package/dist/esm/utils/ens/labelhash.js.map +1 -1
- package/dist/esm/utils/ens/namehash.js +0 -12
- package/dist/esm/utils/ens/namehash.js.map +1 -1
- package/dist/esm/utils/ens/normalize.js +0 -10
- package/dist/esm/utils/ens/normalize.js.map +1 -1
- package/dist/esm/utils/ens/packetToBytes.js +0 -4
- package/dist/esm/utils/ens/packetToBytes.js.map +1 -1
- package/dist/esm/utils/errors/getNodeError.js +3 -2
- package/dist/esm/utils/errors/getNodeError.js.map +1 -1
- package/dist/esm/utils/filters/createFilterRequestScope.js +10 -0
- package/dist/esm/utils/filters/createFilterRequestScope.js.map +1 -0
- package/dist/esm/utils/formatters/block.js +0 -1
- package/dist/esm/utils/formatters/block.js.map +1 -1
- package/dist/esm/utils/formatters/extract.js +0 -3
- package/dist/esm/utils/formatters/extract.js.map +1 -1
- package/dist/esm/utils/formatters/format.js +0 -3
- package/dist/esm/utils/formatters/format.js.map +1 -1
- package/dist/esm/utils/observe.js +0 -5
- package/dist/esm/utils/observe.js.map +1 -1
- package/dist/esm/utils/poll.js +0 -3
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/esm/utils/promise/withCache.js +0 -13
- package/dist/esm/utils/promise/withCache.js.map +1 -1
- package/dist/esm/utils/regex.js +0 -4
- package/dist/esm/utils/regex.js.map +1 -1
- package/dist/esm/utils/rpc.js +4 -14
- package/dist/esm/utils/rpc.js.map +1 -1
- package/dist/esm/utils/signature/hashTypedData.js +0 -3
- package/dist/esm/utils/signature/hashTypedData.js.map +1 -1
- package/dist/esm/utils/signature/recoverAddress.js +0 -2
- package/dist/esm/utils/signature/recoverAddress.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js +0 -4
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/utils/transaction/serializeTransaction.js +2 -4
- package/dist/esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/esm/utils/typedData.js +0 -4
- package/dist/esm/utils/typedData.js.map +1 -1
- package/dist/esm/utils/unit/parseUnits.js +0 -2
- package/dist/esm/utils/unit/parseUnits.js.map +1 -1
- package/dist/types/actions/ens/getEnsAddress.d.ts +28 -5
- package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsAvatar.d.ts +28 -2
- package/dist/types/actions/ens/getEnsAvatar.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsName.d.ts +19 -3
- package/dist/types/actions/ens/getEnsName.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsResolver.d.ts +29 -3
- package/dist/types/actions/ens/getEnsResolver.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsText.d.ts +22 -7
- package/dist/types/actions/ens/getEnsText.d.ts.map +1 -1
- package/dist/types/actions/getContract.d.ts +42 -3
- package/dist/types/actions/getContract.d.ts.map +1 -1
- package/dist/types/actions/public/call.d.ts +29 -1
- package/dist/types/actions/public/call.d.ts.map +1 -1
- package/dist/types/actions/public/createBlockFilter.d.ts +21 -0
- package/dist/types/actions/public/createBlockFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +22 -0
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +23 -0
- package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts +21 -0
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts.map +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +28 -0
- package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/dist/types/actions/public/estimateGas.d.ts +27 -2
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getBalance.d.ts +34 -1
- package/dist/types/actions/public/getBalance.d.ts.map +1 -1
- package/dist/types/actions/public/getBlock.d.ts +28 -1
- package/dist/types/actions/public/getBlock.d.ts.map +1 -1
- package/dist/types/actions/public/getBlockNumber.d.ts +21 -1
- package/dist/types/actions/public/getBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/getBlockTransactionCount.d.ts +23 -0
- package/dist/types/actions/public/getBlockTransactionCount.d.ts.map +1 -1
- package/dist/types/actions/public/getBytecode.d.ts +23 -0
- package/dist/types/actions/public/getBytecode.d.ts.map +1 -1
- package/dist/types/actions/public/getChainId.d.ts +21 -0
- package/dist/types/actions/public/getChainId.d.ts.map +1 -1
- package/dist/types/actions/public/getFeeHistory.d.ts +33 -1
- package/dist/types/actions/public/getFeeHistory.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts +84 -1
- package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts +29 -1
- package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getGasPrice.d.ts +18 -1
- package/dist/types/actions/public/getGasPrice.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts +20 -1
- package/dist/types/actions/public/getLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getStorageAt.d.ts +24 -0
- package/dist/types/actions/public/getStorageAt.d.ts.map +1 -1
- package/dist/types/actions/public/getTransaction.d.ts +24 -1
- package/dist/types/actions/public/getTransaction.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionConfirmations.d.ts +24 -0
- package/dist/types/actions/public/getTransactionConfirmations.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionCount.d.ts +21 -1
- package/dist/types/actions/public/getTransactionCount.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +24 -0
- package/dist/types/actions/public/getTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/multicall.d.ts +39 -0
- package/dist/types/actions/public/multicall.d.ts.map +1 -1
- package/dist/types/actions/public/readContract.d.ts +32 -0
- package/dist/types/actions/public/readContract.d.ts.map +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +32 -0
- package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
- package/dist/types/actions/public/uninstallFilter.d.ts +26 -1
- package/dist/types/actions/public/uninstallFilter.d.ts.map +1 -1
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts +48 -2
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlockNumber.d.ts +25 -1
- package/dist/types/actions/public/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlocks.d.ts +24 -2
- package/dist/types/actions/public/watchBlocks.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +31 -0
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +37 -1
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchPendingTransactions.d.ts +47 -4
- package/dist/types/actions/public/watchPendingTransactions.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +27 -0
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +996 -1
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +25 -0
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/clients/transports/fallback.d.ts +14 -0
- package/dist/types/clients/transports/fallback.d.ts.map +1 -1
- package/dist/types/errors/abi.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/address.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +1 -0
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/block.d.ts.map +1 -1
- package/dist/types/errors/chain.d.ts.map +1 -1
- package/dist/types/errors/contract.d.ts.map +1 -1
- package/dist/types/errors/data.d.ts.map +1 -1
- package/dist/types/errors/encoding.d.ts.map +1 -1
- package/dist/types/errors/ens.d.ts.map +1 -1
- package/dist/types/errors/estimateGas.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +4 -4
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/errors/log.d.ts.map +1 -1
- package/dist/types/errors/node.d.ts.map +1 -1
- package/dist/types/errors/request.d.ts +42 -80
- package/dist/types/errors/request.d.ts.map +1 -1
- package/dist/types/errors/rpc.d.ts +189 -43
- package/dist/types/errors/rpc.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/errors/version.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/eip1193.d.ts +2 -1
- package/dist/types/types/eip1193.d.ts.map +1 -1
- package/dist/types/types/filter.d.ts +2 -0
- package/dist/types/types/filter.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/window.d.ts +2 -4
- package/dist/types/types/window.d.ts.map +1 -1
- package/dist/types/utils/buildRequest.d.ts.map +1 -1
- package/dist/types/utils/errors/getNodeError.d.ts +1 -1
- package/dist/types/utils/errors/getNodeError.d.ts.map +1 -1
- package/dist/types/utils/filters/createFilterRequestScope.d.ts +16 -0
- package/dist/types/utils/filters/createFilterRequestScope.d.ts.map +1 -0
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/ens/getEnsAddress.ts +28 -5
- package/src/actions/ens/getEnsAvatar.ts +28 -2
- package/src/actions/ens/getEnsName.ts +19 -3
- package/src/actions/ens/getEnsResolver.ts +29 -3
- package/src/actions/ens/getEnsText.ts +22 -7
- package/src/actions/getContract.ts +42 -3
- package/src/actions/public/call.ts +29 -1
- package/src/actions/public/createBlockFilter.ts +26 -1
- package/src/actions/public/createContractEventFilter.ts +28 -0
- package/src/actions/public/createEventFilter.ts +30 -0
- package/src/actions/public/createPendingTransactionFilter.ts +26 -1
- package/src/actions/public/estimateContractGas.ts +28 -0
- package/src/actions/public/estimateGas.ts +27 -2
- package/src/actions/public/getBalance.ts +34 -1
- package/src/actions/public/getBlock.ts +28 -1
- package/src/actions/public/getBlockNumber.ts +21 -1
- package/src/actions/public/getBlockTransactionCount.ts +23 -0
- package/src/actions/public/getBytecode.ts +23 -0
- package/src/actions/public/getChainId.ts +21 -0
- package/src/actions/public/getFeeHistory.ts +33 -1
- package/src/actions/public/getFilterChanges.ts +85 -2
- package/src/actions/public/getFilterLogs.ts +30 -2
- package/src/actions/public/getGasPrice.ts +18 -1
- package/src/actions/public/getLogs.ts +20 -1
- package/src/actions/public/getStorageAt.ts +24 -0
- package/src/actions/public/getTransaction.ts +24 -1
- package/src/actions/public/getTransactionConfirmations.ts +24 -0
- package/src/actions/public/getTransactionCount.ts +21 -1
- package/src/actions/public/getTransactionReceipt.ts +24 -0
- package/src/actions/public/multicall.ts +39 -0
- package/src/actions/public/readContract.ts +32 -0
- package/src/actions/public/simulateContract.ts +32 -0
- package/src/actions/public/uninstallFilter.ts +27 -2
- package/src/actions/public/waitForTransactionReceipt.ts +48 -2
- package/src/actions/public/watchBlockNumber.ts +25 -1
- package/src/actions/public/watchBlocks.ts +24 -2
- package/src/actions/public/watchContractEvent.ts +31 -0
- package/src/actions/public/watchEvent.ts +37 -1
- package/src/actions/public/watchPendingTransactions.ts +49 -4
- package/src/actions/wallet/deployContract.ts +27 -0
- package/src/clients/decorators/public.ts +996 -1
- package/src/clients/decorators/wallet.ts +25 -0
- package/src/clients/transports/fallback.ts +46 -2
- package/src/errors/abi.ts +25 -25
- package/src/errors/account.ts +1 -1
- package/src/errors/address.ts +1 -1
- package/src/errors/base.ts +7 -5
- package/src/errors/block.ts +1 -1
- package/src/errors/chain.ts +4 -4
- package/src/errors/contract.ts +7 -7
- package/src/errors/data.ts +1 -1
- package/src/errors/encoding.ts +7 -7
- package/src/errors/ens.ts +4 -4
- package/src/errors/estimateGas.ts +2 -2
- package/src/errors/index.ts +15 -11
- package/src/errors/log.ts +1 -1
- package/src/errors/node.ts +12 -12
- package/src/errors/request.ts +82 -175
- package/src/errors/rpc.ts +355 -89
- package/src/errors/transaction.ts +11 -11
- package/src/errors/version.ts +1 -1
- package/src/index.ts +6 -1
- package/src/types/eip1193.ts +6 -1
- package/src/types/filter.ts +3 -0
- package/src/types/index.ts +2 -0
- package/src/types/window.ts +2 -4
- package/src/utils/buildRequest.ts +19 -1
- package/src/utils/errors/getNodeError.ts +2 -3
- package/src/utils/filters/createFilterRequestScope.ts +42 -0
- package/src/utils/rpc.ts +6 -4
@@ -33,7 +33,10 @@ export type GetBlockParameters = {
|
|
33
33
|
| {
|
34
34
|
blockHash?: never
|
35
35
|
blockNumber?: never
|
36
|
-
/**
|
36
|
+
/**
|
37
|
+
* The block tag.
|
38
|
+
* @default 'latest'
|
39
|
+
*/
|
37
40
|
blockTag?: BlockTag
|
38
41
|
}
|
39
42
|
)
|
@@ -42,6 +45,30 @@ export type GetBlockReturnType<
|
|
42
45
|
TChain extends Chain | undefined = Chain | undefined,
|
43
46
|
> = FormattedBlock<BlockFormatter<TChain>>
|
44
47
|
|
48
|
+
/**
|
49
|
+
* Returns information about a block at a block number, hash, or tag.
|
50
|
+
*
|
51
|
+
* - Docs: https://viem.sh/docs/actions/public/getBlock.html
|
52
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/fetching-blocks
|
53
|
+
* - JSON-RPC Methods:
|
54
|
+
* - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) for `blockNumber` & `blockTag`.
|
55
|
+
* - Calls [`eth_getBlockByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash) for `blockHash`.
|
56
|
+
*
|
57
|
+
* @param client - Client to use
|
58
|
+
* @param parameters - {@link GetBlockParameters}
|
59
|
+
* @returns Information about the block. {@link GetBlockReturnType}
|
60
|
+
*
|
61
|
+
* @example
|
62
|
+
* import { createPublicClient, http } from 'viem'
|
63
|
+
* import { mainnet } from 'viem/chains'
|
64
|
+
* import { getBlock } from 'viem/public'
|
65
|
+
*
|
66
|
+
* const client = createPublicClient({
|
67
|
+
* chain: mainnet,
|
68
|
+
* transport: http(),
|
69
|
+
* })
|
70
|
+
* const block = await getBlock(client)
|
71
|
+
*/
|
45
72
|
export async function getBlock<
|
46
73
|
TChain extends Chain | undefined,
|
47
74
|
TAccount extends Account | undefined,
|
@@ -16,7 +16,27 @@ export function getBlockNumberCache(id: string) {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
/**
|
19
|
-
*
|
19
|
+
* Returns the number of the most recent block seen.
|
20
|
+
*
|
21
|
+
* - Docs: https://viem.sh/docs/actions/public/getBlockNumber.html
|
22
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/fetching-blocks
|
23
|
+
* - JSON-RPC Methods: [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber)
|
24
|
+
*
|
25
|
+
* @param client - Client to use
|
26
|
+
* @param parameters - {@link GetBlockNumberParameters}
|
27
|
+
* @returns The number of the block. {@link GetBlockNumberReturnType}
|
28
|
+
*
|
29
|
+
* @example
|
30
|
+
* import { createPublicClient, http } from 'viem'
|
31
|
+
* import { mainnet } from 'viem/chains'
|
32
|
+
* import { getBlockNumber } from 'viem/public'
|
33
|
+
*
|
34
|
+
* const client = createPublicClient({
|
35
|
+
* chain: mainnet,
|
36
|
+
* transport: http(),
|
37
|
+
* })
|
38
|
+
* const blockNumber = await getBlockNumber(client)
|
39
|
+
* // 69420n
|
20
40
|
*/
|
21
41
|
export async function getBlockNumber<TChain extends Chain | undefined>(
|
22
42
|
client: PublicClient<Transport, TChain>,
|
@@ -24,6 +24,29 @@ export type GetBlockTransactionCountParameters =
|
|
24
24
|
|
25
25
|
export type GetBlockTransactionCountReturnType = number
|
26
26
|
|
27
|
+
/**
|
28
|
+
* Returns the number of Transactions at a block number, hash, or tag.
|
29
|
+
*
|
30
|
+
* - Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount.html
|
31
|
+
* - JSON-RPC Methods:
|
32
|
+
* - Calls [`eth_getBlockTransactionCountByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber) for `blockNumber` & `blockTag`.
|
33
|
+
* - Calls [`eth_getBlockTransactionCountByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash) for `blockHash`.
|
34
|
+
*
|
35
|
+
* @param client - Client to use
|
36
|
+
* @param parameters - {@link GetBlockTransactionCountParameters}
|
37
|
+
* @returns The block transaction count. {@link GetBlockTransactionCountReturnType}
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
* import { createPublicClient, http } from 'viem'
|
41
|
+
* import { mainnet } from 'viem/chains'
|
42
|
+
* import { getBlockTransactionCount } from 'viem/public'
|
43
|
+
*
|
44
|
+
* const client = createPublicClient({
|
45
|
+
* chain: mainnet,
|
46
|
+
* transport: http(),
|
47
|
+
* })
|
48
|
+
* const count = await getBlockTransactionCount(client)
|
49
|
+
*/
|
27
50
|
export async function getBlockTransactionCount<
|
28
51
|
TChain extends Chain | undefined,
|
29
52
|
>(
|
@@ -17,6 +17,29 @@ export type GetBytecodeParameters = {
|
|
17
17
|
|
18
18
|
export type GetBytecodeReturnType = Hex | undefined
|
19
19
|
|
20
|
+
/**
|
21
|
+
* Retrieves the bytecode at an address.
|
22
|
+
*
|
23
|
+
* - Docs: https://viem.sh/docs/contract/getBytecode.html
|
24
|
+
* - JSON-RPC Methods: [`eth_getCode`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode)
|
25
|
+
*
|
26
|
+
* @param client - Client to use
|
27
|
+
* @param parameters - {@link GetBytecodeParameters}
|
28
|
+
* @returns The contract's bytecode. {@link GetBytecodeReturnType}
|
29
|
+
*
|
30
|
+
* @example
|
31
|
+
* import { createPublicClient, http } from 'viem'
|
32
|
+
* import { mainnet } from 'viem/chains'
|
33
|
+
* import { getBytecode } from 'viem/contract'
|
34
|
+
*
|
35
|
+
* const client = createPublicClient({
|
36
|
+
* chain: mainnet,
|
37
|
+
* transport: http(),
|
38
|
+
* })
|
39
|
+
* const code = await getBytecode(client, {
|
40
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
41
|
+
* })
|
42
|
+
*/
|
20
43
|
export async function getBytecode<TChain extends Chain | undefined>(
|
21
44
|
client: PublicClient<Transport, TChain>,
|
22
45
|
{ address, blockNumber, blockTag = 'latest' }: GetBytecodeParameters,
|
@@ -8,6 +8,27 @@ import { hexToNumber } from '../../utils/index.js'
|
|
8
8
|
|
9
9
|
export type GetChainIdReturnType = number
|
10
10
|
|
11
|
+
/**
|
12
|
+
* Returns the chain ID associated with the current network.
|
13
|
+
*
|
14
|
+
* - Docs: https://viem.sh/docs/actions/public/getChainId.html
|
15
|
+
* - JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)
|
16
|
+
*
|
17
|
+
* @param client - Client to use
|
18
|
+
* @returns The current chain ID. {@link GetChainIdReturnType}
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* import { createPublicClient, http } from 'viem'
|
22
|
+
* import { mainnet } from 'viem/chains'
|
23
|
+
* import { getChainId } from 'viem/public'
|
24
|
+
*
|
25
|
+
* const client = createPublicClient({
|
26
|
+
* chain: mainnet,
|
27
|
+
* transport: http(),
|
28
|
+
* })
|
29
|
+
* const chainId = await getChainId(client)
|
30
|
+
* // 1
|
31
|
+
*/
|
11
32
|
export async function getChainId<
|
12
33
|
TChain extends Chain | undefined,
|
13
34
|
TAccount extends Account | undefined,
|
@@ -5,14 +5,25 @@ import { numberToHex } from '../../utils/index.js'
|
|
5
5
|
import { formatFeeHistory } from '../../utils/formatters/index.js'
|
6
6
|
|
7
7
|
export type GetFeeHistoryParameters = {
|
8
|
+
/**
|
9
|
+
* Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.
|
10
|
+
*/
|
8
11
|
blockCount: number
|
12
|
+
/**
|
13
|
+
* A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used.
|
14
|
+
*/
|
9
15
|
rewardPercentiles: number[]
|
10
16
|
} & (
|
11
17
|
| {
|
12
18
|
blockNumber?: never
|
19
|
+
/**
|
20
|
+
* Highest number block of the requested range.
|
21
|
+
* @default 'latest'
|
22
|
+
*/
|
13
23
|
blockTag?: BlockTag
|
14
24
|
}
|
15
25
|
| {
|
26
|
+
/** Highest number block of the requested range. */
|
16
27
|
blockNumber?: bigint
|
17
28
|
blockTag?: never
|
18
29
|
}
|
@@ -20,7 +31,28 @@ export type GetFeeHistoryParameters = {
|
|
20
31
|
export type GetFeeHistoryReturnType = FeeHistory
|
21
32
|
|
22
33
|
/**
|
23
|
-
*
|
34
|
+
* Returns a collection of historical gas information.
|
35
|
+
*
|
36
|
+
* - Docs: https://viem.sh/docs/actions/public/getFeeHistory.html
|
37
|
+
* - JSON-RPC Methods: [`eth_feeHistory`](https://docs.alchemy.com/reference/eth-feehistory)
|
38
|
+
*
|
39
|
+
* @param client - Client to use
|
40
|
+
* @param parameters - {@link GetFeeHistoryParameters}
|
41
|
+
* @returns The gas estimate (in wei). {@link GetFeeHistoryReturnType}
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* import { createPublicClient, http } from 'viem'
|
45
|
+
* import { mainnet } from 'viem/chains'
|
46
|
+
* import { getFeeHistory } from 'viem/public'
|
47
|
+
*
|
48
|
+
* const client = createPublicClient({
|
49
|
+
* chain: mainnet,
|
50
|
+
* transport: http(),
|
51
|
+
* })
|
52
|
+
* const feeHistory = await getFeeHistory(client, {
|
53
|
+
* blockCount: 4,
|
54
|
+
* rewardPercentiles: [25, 75],
|
55
|
+
* })
|
24
56
|
*/
|
25
57
|
export async function getFeeHistory<TChain extends Chain | undefined>(
|
26
58
|
client: PublicClient<Transport, TChain>,
|
@@ -30,6 +30,89 @@ export type GetFilterChangesReturnType<
|
|
30
30
|
? Log<bigint, number, TAbiEvent, TAbi, TEventName>[]
|
31
31
|
: Hash[]
|
32
32
|
|
33
|
+
/**
|
34
|
+
* Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.
|
35
|
+
*
|
36
|
+
* - Docs: https://viem.sh/docs/actions/public/getFilterChanges.html
|
37
|
+
* - JSON-RPC Methods: [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)
|
38
|
+
*
|
39
|
+
* @remarks
|
40
|
+
* A Filter can be created from the following actions:
|
41
|
+
*
|
42
|
+
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
43
|
+
* - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)
|
44
|
+
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
45
|
+
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
46
|
+
*
|
47
|
+
* Depending on the type of filter, the return value will be different:
|
48
|
+
*
|
49
|
+
* - If the filter was created with `createContractEventFilter` or `createEventFilter`, it returns a list of logs.
|
50
|
+
* - If the filter was created with `createPendingTransactionFilter`, it returns a list of transaction hashes.
|
51
|
+
* - If the filter was created with `createBlockFilter`, it returns a list of block hashes.
|
52
|
+
*
|
53
|
+
* @param client - Client to use
|
54
|
+
* @param parameters - {@link GetFilterChangesParameters}
|
55
|
+
* @returns Logs or hashes. {@link GetFilterChangesReturnType}
|
56
|
+
*
|
57
|
+
* @example
|
58
|
+
* // Blocks
|
59
|
+
* import { createPublicClient, http } from 'viem'
|
60
|
+
* import { mainnet } from 'viem/chains'
|
61
|
+
* import { createBlockFilter, getFilterChanges } from 'viem/public'
|
62
|
+
*
|
63
|
+
* const client = createPublicClient({
|
64
|
+
* chain: mainnet,
|
65
|
+
* transport: http(),
|
66
|
+
* })
|
67
|
+
* const filter = await createBlockFilter(client)
|
68
|
+
* const hashes = await getFilterChanges(client, { filter })
|
69
|
+
*
|
70
|
+
* @example
|
71
|
+
* // Contract Events
|
72
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
73
|
+
* import { mainnet } from 'viem/chains'
|
74
|
+
* import { createContractEventFilter, getFilterChanges } from 'viem/public'
|
75
|
+
*
|
76
|
+
* const client = createPublicClient({
|
77
|
+
* chain: mainnet,
|
78
|
+
* transport: http(),
|
79
|
+
* })
|
80
|
+
* const filter = await createContractEventFilter(client, {
|
81
|
+
* address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
82
|
+
* abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
|
83
|
+
* eventName: 'Transfer',
|
84
|
+
* })
|
85
|
+
* const logs = await getFilterChanges(client, { filter })
|
86
|
+
*
|
87
|
+
* @example
|
88
|
+
* // Raw Events
|
89
|
+
* import { createPublicClient, http, parseAbiItem } from 'viem'
|
90
|
+
* import { mainnet } from 'viem/chains'
|
91
|
+
* import { createEventFilter, getFilterChanges } from 'viem/public'
|
92
|
+
*
|
93
|
+
* const client = createPublicClient({
|
94
|
+
* chain: mainnet,
|
95
|
+
* transport: http(),
|
96
|
+
* })
|
97
|
+
* const filter = await createEventFilter(client, {
|
98
|
+
* address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
99
|
+
* event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
|
100
|
+
* })
|
101
|
+
* const logs = await getFilterChanges(client, { filter })
|
102
|
+
*
|
103
|
+
* @example
|
104
|
+
* // Transactions
|
105
|
+
* import { createPublicClient, http } from 'viem'
|
106
|
+
* import { mainnet } from 'viem/chains'
|
107
|
+
* import { createPendingTransactionFilter, getFilterChanges } from 'viem/public'
|
108
|
+
*
|
109
|
+
* const client = createPublicClient({
|
110
|
+
* chain: mainnet,
|
111
|
+
* transport: http(),
|
112
|
+
* })
|
113
|
+
* const filter = await createPendingTransactionFilter(client)
|
114
|
+
* const hashes = await getFilterChanges(client, { filter })
|
115
|
+
*/
|
33
116
|
export async function getFilterChanges<
|
34
117
|
TTransport extends Transport,
|
35
118
|
TChain extends Chain | undefined,
|
@@ -38,12 +121,12 @@ export async function getFilterChanges<
|
|
38
121
|
TAbi extends Abi | readonly unknown[],
|
39
122
|
TEventName extends string | undefined,
|
40
123
|
>(
|
41
|
-
|
124
|
+
_client: PublicClient<TTransport, TChain>,
|
42
125
|
{
|
43
126
|
filter,
|
44
127
|
}: GetFilterChangesParameters<TFilterType, TAbiEvent, TAbi, TEventName>,
|
45
128
|
) {
|
46
|
-
const logs = await
|
129
|
+
const logs = await filter.request({
|
47
130
|
method: 'eth_getFilterChanges',
|
48
131
|
params: [filter.id],
|
49
132
|
})
|
@@ -23,16 +23,44 @@ export type GetFilterLogsReturnType<
|
|
23
23
|
TEventName extends string | undefined = MaybeAbiEventName<TAbiEvent>,
|
24
24
|
> = Log<bigint, number, TAbiEvent, TAbi, TEventName>[]
|
25
25
|
|
26
|
+
/**
|
27
|
+
* Returns a list of event logs since the filter was created.
|
28
|
+
*
|
29
|
+
* - Docs: https://viem.sh/docs/actions/public/getFilterLogs.html
|
30
|
+
* - JSON-RPC Methods: [`eth_getFilterLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterlogs)
|
31
|
+
*
|
32
|
+
* @remarks
|
33
|
+
* `getFilterLogs` is only compatible with **event filters**.
|
34
|
+
*
|
35
|
+
* @param client - Client to use
|
36
|
+
* @param parameters - {@link GetFilterLogsParameters}
|
37
|
+
* @returns A list of event logs. {@link GetFilterLogsReturnType}
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
* import { createPublicClient, http, parseAbiItem } from 'viem'
|
41
|
+
* import { mainnet } from 'viem/chains'
|
42
|
+
* import { createEventFilter, getFilterLogs } from 'viem/public'
|
43
|
+
*
|
44
|
+
* const client = createPublicClient({
|
45
|
+
* chain: mainnet,
|
46
|
+
* transport: http(),
|
47
|
+
* })
|
48
|
+
* const filter = await createEventFilter(client, {
|
49
|
+
* address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
50
|
+
* event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
|
51
|
+
* })
|
52
|
+
* const logs = await getFilterLogs(client, { filter })
|
53
|
+
*/
|
26
54
|
export async function getFilterLogs<
|
27
55
|
TChain extends Chain | undefined,
|
28
56
|
TAbiEvent extends AbiEvent | undefined,
|
29
57
|
TAbi extends Abi | readonly unknown[],
|
30
58
|
TEventName extends string | undefined,
|
31
59
|
>(
|
32
|
-
|
60
|
+
_client: PublicClient<Transport, TChain>,
|
33
61
|
{ filter }: GetFilterLogsParameters<TAbiEvent, TAbi, TEventName>,
|
34
62
|
): Promise<GetFilterLogsReturnType<TAbiEvent, TAbi, TEventName>> {
|
35
|
-
const logs = await
|
63
|
+
const logs = await filter.request({
|
36
64
|
method: 'eth_getFilterLogs',
|
37
65
|
params: [filter.id],
|
38
66
|
})
|
@@ -8,7 +8,24 @@ import type { Account, Chain } from '../../types/index.js'
|
|
8
8
|
export type GetGasPriceReturnType = bigint
|
9
9
|
|
10
10
|
/**
|
11
|
-
*
|
11
|
+
* Returns the current price of gas (in wei).
|
12
|
+
*
|
13
|
+
* - Docs: https://viem.sh/docs/actions/public/getGasPrice.html
|
14
|
+
* - JSON-RPC Methods: [`eth_gasPrice`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice)
|
15
|
+
*
|
16
|
+
* @param client - Client to use
|
17
|
+
* @returns The gas price (in wei). {@link GetGasPriceReturnType}
|
18
|
+
*
|
19
|
+
* @example
|
20
|
+
* import { createPublicClient, http } from 'viem'
|
21
|
+
* import { mainnet } from 'viem/chains'
|
22
|
+
* import { getGasPrice } from 'viem/public'
|
23
|
+
*
|
24
|
+
* const client = createPublicClient({
|
25
|
+
* chain: mainnet,
|
26
|
+
* transport: http(),
|
27
|
+
* })
|
28
|
+
* const gasPrice = await getGasPrice(client)
|
12
29
|
*/
|
13
30
|
export async function getGasPrice<
|
14
31
|
TChain extends Chain | undefined,
|
@@ -58,7 +58,26 @@ export type GetLogsReturnType<
|
|
58
58
|
> = Log<bigint, number, TAbiEvent, [TAbiEvent], TEventName>[]
|
59
59
|
|
60
60
|
/**
|
61
|
-
*
|
61
|
+
* Returns a list of event logs matching the provided parameters.
|
62
|
+
*
|
63
|
+
* - Docs: https://viem.sh/docs/actions/public/getLogs.html
|
64
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/filters-and-logs/event-logs
|
65
|
+
* - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
66
|
+
*
|
67
|
+
* @param client - Client to use
|
68
|
+
* @param parameters - {@link GetLogsParameters}
|
69
|
+
* @returns A list of event logs. {@link GetLogsReturnType}
|
70
|
+
*
|
71
|
+
* @example
|
72
|
+
* import { createPublicClient, http, parseAbiItem } from 'viem'
|
73
|
+
* import { mainnet } from 'viem/chains'
|
74
|
+
* import { getLogs } from 'viem/public'
|
75
|
+
*
|
76
|
+
* const client = createPublicClient({
|
77
|
+
* chain: mainnet,
|
78
|
+
* transport: http(),
|
79
|
+
* })
|
80
|
+
* const logs = await getLogs(client)
|
62
81
|
*/
|
63
82
|
export async function getLogs<
|
64
83
|
TChain extends Chain | undefined,
|
@@ -18,6 +18,30 @@ export type GetStorageAtParameters = {
|
|
18
18
|
|
19
19
|
export type GetStorageAtReturnType = Hex | undefined
|
20
20
|
|
21
|
+
/**
|
22
|
+
* Returns the value from a storage slot at a given address.
|
23
|
+
*
|
24
|
+
* - Docs: https://viem.sh/docs/contract/getStorageAt.html
|
25
|
+
* - JSON-RPC Methods: [`eth_getStorageAt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getstorageat)
|
26
|
+
*
|
27
|
+
* @param client - Client to use
|
28
|
+
* @param parameters - {@link GetStorageAtParameters}
|
29
|
+
* @returns The value of the storage slot. {@link GetStorageAtReturnType}
|
30
|
+
*
|
31
|
+
* @example
|
32
|
+
* import { createPublicClient, http } from 'viem'
|
33
|
+
* import { mainnet } from 'viem/chains'
|
34
|
+
* import { getStorageAt } from 'viem/contract'
|
35
|
+
*
|
36
|
+
* const client = createPublicClient({
|
37
|
+
* chain: mainnet,
|
38
|
+
* transport: http(),
|
39
|
+
* })
|
40
|
+
* const code = await getStorageAt(client, {
|
41
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
42
|
+
* slot: toHex(0),
|
43
|
+
* })
|
44
|
+
*/
|
21
45
|
export async function getStorageAt<TChain extends Chain | undefined>(
|
22
46
|
client: PublicClient<Transport, TChain>,
|
23
47
|
{ address, blockNumber, blockTag = 'latest', slot }: GetStorageAtParameters,
|
@@ -53,7 +53,30 @@ export type GetTransactionParameters =
|
|
53
53
|
export type GetTransactionReturnType<TChain extends Chain | undefined = Chain> =
|
54
54
|
FormattedTransaction<TransactionFormatter<TChain>>
|
55
55
|
|
56
|
-
/**
|
56
|
+
/**
|
57
|
+
* Returns information about a [Transaction](https://viem.sh/docs/glossary/terms#transaction) given a hash or block identifier.
|
58
|
+
*
|
59
|
+
* - Docs: https://viem.sh/docs/actions/public/getTransaction.html
|
60
|
+
* - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions
|
61
|
+
* - JSON-RPC Methods: [`eth_getTransactionByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionByHash)
|
62
|
+
*
|
63
|
+
* @param client - Client to use
|
64
|
+
* @param parameters - {@link GetTransactionParameters}
|
65
|
+
* @returns The transaction information. {@link GetTransactionReturnType}
|
66
|
+
*
|
67
|
+
* @example
|
68
|
+
* import { createPublicClient, http } from 'viem'
|
69
|
+
* import { mainnet } from 'viem/chains'
|
70
|
+
* import { getTransaction } from 'viem/public'
|
71
|
+
*
|
72
|
+
* const client = createPublicClient({
|
73
|
+
* chain: mainnet,
|
74
|
+
* transport: http(),
|
75
|
+
* })
|
76
|
+
* const transaction = await getTransaction(client, {
|
77
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
78
|
+
* })
|
79
|
+
*/
|
57
80
|
export async function getTransaction<TChain extends Chain | undefined>(
|
58
81
|
client: PublicClient<Transport, TChain>,
|
59
82
|
{
|
@@ -25,6 +25,30 @@ export type GetTransactionConfirmationsParameters<
|
|
25
25
|
|
26
26
|
export type GetTransactionConfirmationsReturnType = bigint
|
27
27
|
|
28
|
+
/**
|
29
|
+
* Returns the number of blocks passed (confirmations) since the transaction was processed on a block.
|
30
|
+
*
|
31
|
+
* - Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations.html
|
32
|
+
* - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions
|
33
|
+
* - JSON-RPC Methods: [`eth_getTransactionConfirmations`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionConfirmations)
|
34
|
+
*
|
35
|
+
* @param client - Client to use
|
36
|
+
* @param parameters - {@link GetTransactionConfirmationsParameters}
|
37
|
+
* @returns The number of blocks passed since the transaction was processed. If confirmations is 0, then the Transaction has not been confirmed & processed yet. {@link GetTransactionConfirmationsReturnType}
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
* import { createPublicClient, http } from 'viem'
|
41
|
+
* import { mainnet } from 'viem/chains'
|
42
|
+
* import { getTransactionConfirmations } from 'viem/public'
|
43
|
+
*
|
44
|
+
* const client = createPublicClient({
|
45
|
+
* chain: mainnet,
|
46
|
+
* transport: http(),
|
47
|
+
* })
|
48
|
+
* const confirmations = await getTransactionConfirmations(client, {
|
49
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
50
|
+
* })
|
51
|
+
*/
|
28
52
|
export async function getTransactionConfirmations<
|
29
53
|
TChain extends Chain | undefined,
|
30
54
|
>(
|
@@ -24,7 +24,27 @@ export type GetTransactionCountParameters = {
|
|
24
24
|
export type GetTransactionCountReturnType = number
|
25
25
|
|
26
26
|
/**
|
27
|
-
*
|
27
|
+
* Returns the number of [Transactions](https://viem.sh/docs/glossary/terms#transaction) an Account has broadcast / sent.
|
28
|
+
*
|
29
|
+
* - Docs: https://viem.sh/docs/actions/public/getTransactionCount.html
|
30
|
+
* - JSON-RPC Methods: [`eth_getTransactionCount`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactioncount)
|
31
|
+
*
|
32
|
+
* @param client - Client to use
|
33
|
+
* @param parameters - {@link GetTransactionCountParameters}
|
34
|
+
* @returns The number of transactions an account has sent. {@link GetTransactionCountReturnType}
|
35
|
+
*
|
36
|
+
* @example
|
37
|
+
* import { createPublicClient, http } from 'viem'
|
38
|
+
* import { mainnet } from 'viem/chains'
|
39
|
+
* import { getTransactionCount } from 'viem/public'
|
40
|
+
*
|
41
|
+
* const client = createPublicClient({
|
42
|
+
* chain: mainnet,
|
43
|
+
* transport: http(),
|
44
|
+
* })
|
45
|
+
* const transactionCount = await getTransactionCount(client, {
|
46
|
+
* address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
47
|
+
* })
|
28
48
|
*/
|
29
49
|
export async function getTransactionCount<
|
30
50
|
TChain extends Chain | undefined,
|
@@ -17,6 +17,30 @@ export type GetTransactionReceiptReturnType<
|
|
17
17
|
TChain extends Chain | undefined = Chain | undefined,
|
18
18
|
> = FormattedTransactionReceipt<TransactionReceiptFormatter<TChain>>
|
19
19
|
|
20
|
+
/**
|
21
|
+
* Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.
|
22
|
+
*
|
23
|
+
* - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt.html
|
24
|
+
* - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions
|
25
|
+
* - JSON-RPC Methods: [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt)
|
26
|
+
*
|
27
|
+
* @param client - Client to use
|
28
|
+
* @param parameters - {@link GetTransactionReceiptParameters}
|
29
|
+
* @returns The transaction receipt. {@link GetTransactionReceiptReturnType}
|
30
|
+
*
|
31
|
+
* @example
|
32
|
+
* import { createPublicClient, http } from 'viem'
|
33
|
+
* import { mainnet } from 'viem/chains'
|
34
|
+
* import { getTransactionReceipt } from 'viem/public'
|
35
|
+
*
|
36
|
+
* const client = createPublicClient({
|
37
|
+
* chain: mainnet,
|
38
|
+
* transport: http(),
|
39
|
+
* })
|
40
|
+
* const transactionReceipt = await getTransactionReceipt(client, {
|
41
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
42
|
+
* })
|
43
|
+
*/
|
20
44
|
export async function getTransactionReceipt<TChain extends Chain | undefined>(
|
21
45
|
client: PublicClient<Transport, TChain>,
|
22
46
|
{ hash }: GetTransactionReceiptParameters,
|
@@ -38,6 +38,45 @@ export type MulticallReturnType<
|
|
38
38
|
TAllowFailure extends boolean = true,
|
39
39
|
> = MulticallResults<TContracts, TAllowFailure>
|
40
40
|
|
41
|
+
/**
|
42
|
+
* Similar to [`readContract`](https://viem.sh/docs/contract/readContract), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).
|
43
|
+
*
|
44
|
+
* - Docs: https://viem.sh/docs/contract/multicall.html
|
45
|
+
*
|
46
|
+
* @param client - Client to use
|
47
|
+
* @param parameters - {@link MulticallParameters}
|
48
|
+
* @returns An array of results with accompanying status. {@link MulticallReturnType}
|
49
|
+
*
|
50
|
+
* @example
|
51
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
52
|
+
* import { mainnet } from 'viem/chains'
|
53
|
+
* import { multicall } from 'viem/contract'
|
54
|
+
*
|
55
|
+
* const client = createPublicClient({
|
56
|
+
* chain: mainnet,
|
57
|
+
* transport: http(),
|
58
|
+
* })
|
59
|
+
* const abi = parseAbi([
|
60
|
+
* 'function balanceOf(address) view returns (uint256)',
|
61
|
+
* 'function totalSupply() view returns (uint256)',
|
62
|
+
* ])
|
63
|
+
* const results = await multicall(client, {
|
64
|
+
* contracts: [
|
65
|
+
* {
|
66
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
67
|
+
* abi,
|
68
|
+
* functionName: 'balanceOf',
|
69
|
+
* args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
|
70
|
+
* },
|
71
|
+
* {
|
72
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
73
|
+
* abi,
|
74
|
+
* functionName: 'totalSupply',
|
75
|
+
* },
|
76
|
+
* ],
|
77
|
+
* })
|
78
|
+
* // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
|
79
|
+
*/
|
41
80
|
export async function multicall<
|
42
81
|
TChain extends Chain | undefined,
|
43
82
|
TContracts extends ContractFunctionConfig[],
|
@@ -30,6 +30,38 @@ export type ReadContractReturnType<
|
|
30
30
|
TFunctionName extends string = string,
|
31
31
|
> = ContractFunctionResult<TAbi, TFunctionName>
|
32
32
|
|
33
|
+
/**
|
34
|
+
* Calls a read-only function on a contract, and returns the response.
|
35
|
+
*
|
36
|
+
* - Docs: https://viem.sh/docs/contract/readContract.html
|
37
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/reading-contracts
|
38
|
+
*
|
39
|
+
* @remarks
|
40
|
+
* A "read-only" function (constant function) on a Solidity contract is denoted by a `view` or `pure` keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas.
|
41
|
+
*
|
42
|
+
* Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
43
|
+
*
|
44
|
+
* @param client - Client to use
|
45
|
+
* @param parameters - {@link ReadContractParameters}
|
46
|
+
* @returns The response from the contract. Type is inferred. {@link ReadContractReturnType}
|
47
|
+
*
|
48
|
+
* @example
|
49
|
+
* import { createPublicClient, http } from 'viem'
|
50
|
+
* import { mainnet } from 'viem/chains'
|
51
|
+
* import { readContract } from 'viem/contract'
|
52
|
+
*
|
53
|
+
* const client = createPublicClient({
|
54
|
+
* chain: mainnet,
|
55
|
+
* transport: http(),
|
56
|
+
* })
|
57
|
+
* const results = await readContract(client, {
|
58
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
59
|
+
* abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
|
60
|
+
* functionName: 'balanceOf',
|
61
|
+
* args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
|
62
|
+
* })
|
63
|
+
* // 424122n
|
64
|
+
*/
|
33
65
|
export async function readContract<
|
34
66
|
TChain extends Chain | undefined,
|
35
67
|
TAbi extends Abi | readonly unknown[],
|