viem 0.3.0-tsc-nodenext-2.20230407T050527 → 0.3.1
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 +10 -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/index.js +2 -1
- package/dist/cjs/utils/index.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/index.js +3 -1
- package/dist/cjs/utils/signature/index.js.map +1 -1
- package/dist/cjs/utils/signature/recoverAddress.js +2 -13
- package/dist/cjs/utils/signature/recoverAddress.js.map +1 -1
- package/dist/cjs/utils/signature/recoverPublicKey.js +18 -0
- package/dist/cjs/utils/signature/recoverPublicKey.js.map +1 -0
- 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 +2 -2
- 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/index.js +1 -1
- package/dist/esm/utils/index.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/index.js +1 -0
- package/dist/esm/utils/signature/index.js.map +1 -1
- package/dist/esm/utils/signature/recoverAddress.js +2 -13
- package/dist/esm/utils/signature/recoverAddress.js.map +1 -1
- package/dist/esm/utils/signature/recoverPublicKey.js +14 -0
- package/dist/esm/utils/signature/recoverPublicKey.js.map +1 -0
- 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 +22 -3
- 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 +4 -4
- 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/abi/getAbiItem.d.ts +1 -1
- package/dist/types/utils/abi/getAbiItem.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/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/dist/types/utils/signature/index.d.ts +2 -0
- package/dist/types/utils/signature/index.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverAddress.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverPublicKey.d.ts +8 -0
- package/dist/types/utils/signature/recoverPublicKey.d.ts.map +1 -0
- package/package.json +2 -2
- 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 +23 -4
- 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 +9 -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/abi/getAbiItem.ts +9 -8
- 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/index.ts +3 -0
- package/src/utils/rpc.ts +6 -4
- package/src/utils/signature/index.ts +6 -0
- package/src/utils/signature/recoverAddress.ts +2 -17
- package/src/utils/signature/recoverPublicKey.ts +30 -0
@@ -49,7 +49,10 @@ export type EstimateGasParameters<
|
|
49
49
|
}
|
50
50
|
| {
|
51
51
|
blockNumber?: never
|
52
|
-
/**
|
52
|
+
/**
|
53
|
+
* The balance of the account at a block tag.
|
54
|
+
* @default 'latest'
|
55
|
+
*/
|
53
56
|
blockTag?: BlockTag
|
54
57
|
}
|
55
58
|
)
|
@@ -57,7 +60,29 @@ export type EstimateGasParameters<
|
|
57
60
|
export type EstimateGasReturnType = bigint
|
58
61
|
|
59
62
|
/**
|
60
|
-
*
|
63
|
+
* Estimates the gas necessary to complete a transaction without submitting it to the network.
|
64
|
+
*
|
65
|
+
* - Docs: https://viem.sh/docs/actions/public/estimateGas.html
|
66
|
+
* - JSON-RPC Methods: [`eth_estimateGas`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)
|
67
|
+
*
|
68
|
+
* @param client - Client to use
|
69
|
+
* @param parameters - {@link EstimateGasParameters}
|
70
|
+
* @returns The gas estimate (in wei). {@link EstimateGasReturnType}
|
71
|
+
*
|
72
|
+
* @example
|
73
|
+
* import { createPublicClient, http, parseEther } from 'viem'
|
74
|
+
* import { mainnet } from 'viem/chains'
|
75
|
+
* import { estimateGas } from 'viem/public'
|
76
|
+
*
|
77
|
+
* const client = createPublicClient({
|
78
|
+
* chain: mainnet,
|
79
|
+
* transport: http(),
|
80
|
+
* })
|
81
|
+
* const gasEstimate = await estimateGas(client, {
|
82
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
83
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
84
|
+
* value: parseEther('1'),
|
85
|
+
* })
|
61
86
|
*/
|
62
87
|
export async function estimateGas<
|
63
88
|
TChain extends Chain | undefined,
|
@@ -21,7 +21,40 @@ export type GetBalanceParameters = {
|
|
21
21
|
export type GetBalanceReturnType = bigint
|
22
22
|
|
23
23
|
/**
|
24
|
-
*
|
24
|
+
* Returns the balance of an address in wei.
|
25
|
+
*
|
26
|
+
* - Docs: https://viem.sh/docs/actions/public/getBalance.html
|
27
|
+
* - JSON-RPC Methods: [`eth_getBalance`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance)
|
28
|
+
*
|
29
|
+
* @remarks
|
30
|
+
* You can convert the balance to ether units with [`formatEther`](https://viem.sh/docs/utilities/formatEther.html).
|
31
|
+
*
|
32
|
+
* ```ts
|
33
|
+
* const balance = await getBalance(client, {
|
34
|
+
* address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
35
|
+
* blockTag: 'safe'
|
36
|
+
* })
|
37
|
+
* const balanceAsEther = formatEther(balance)
|
38
|
+
* // "6.942"
|
39
|
+
* ```
|
40
|
+
*
|
41
|
+
* @param client - Client to use
|
42
|
+
* @param parameters - {@link GetBalanceParameters}
|
43
|
+
* @returns The balance of the address in wei. {@link GetBalanceReturnType}
|
44
|
+
*
|
45
|
+
* @example
|
46
|
+
* import { createPublicClient, http } from 'viem'
|
47
|
+
* import { mainnet } from 'viem/chains'
|
48
|
+
* import { getBalance } from 'viem/public'
|
49
|
+
*
|
50
|
+
* const client = createPublicClient({
|
51
|
+
* chain: mainnet,
|
52
|
+
* transport: http(),
|
53
|
+
* })
|
54
|
+
* const balance = await getBalance(client, {
|
55
|
+
* address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
56
|
+
* })
|
57
|
+
* // 10000000000000000000000n (wei)
|
25
58
|
*/
|
26
59
|
export async function getBalance<TChain extends Chain | undefined>(
|
27
60
|
client: PublicClient<Transport, TChain>,
|
@@ -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,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { AbiEvent } from 'abitype'
|
1
|
+
import type { AbiEvent, Narrow } from 'abitype'
|
2
2
|
import type { PublicClient, Transport } from '../../clients/index.js'
|
3
3
|
import type {
|
4
4
|
Address,
|
@@ -28,7 +28,7 @@ export type GetLogsParameters<
|
|
28
28
|
address?: Address | Address[]
|
29
29
|
} & (
|
30
30
|
| {
|
31
|
-
event: TAbiEvent
|
31
|
+
event: Narrow<TAbiEvent>
|
32
32
|
args?: MaybeExtractEventArgsFromAbi<[TAbiEvent], TEventName>
|
33
33
|
}
|
34
34
|
| {
|
@@ -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,
|
@@ -78,7 +97,7 @@ export async function getLogs<
|
|
78
97
|
if (event)
|
79
98
|
topics = encodeEventTopics({
|
80
99
|
abi: [event],
|
81
|
-
eventName: event.name,
|
100
|
+
eventName: (event as AbiEvent).name,
|
82
101
|
args,
|
83
102
|
} as EncodeEventTopicsParameters)
|
84
103
|
|
@@ -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,
|