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
@@ -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[],
|
@@ -57,6 +57,38 @@ export type SimulateContractReturnType<
|
|
57
57
|
} & ContractFunctionConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'>
|
58
58
|
}
|
59
59
|
|
60
|
+
/**
|
61
|
+
* Simulates/validates a contract interaction. This is useful for retrieving **return data** and **revert reasons** of contract write functions.
|
62
|
+
*
|
63
|
+
* - Docs: https://viem.sh/docs/contract/simulateContract.html
|
64
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts
|
65
|
+
*
|
66
|
+
* @remarks
|
67
|
+
* This function does not require gas to execute and _**does not**_ change the state of the blockchain. It is almost identical to [`readContract`](https://viem.sh/docs/contract/readContract), but also supports contract write functions.
|
68
|
+
*
|
69
|
+
* 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).
|
70
|
+
*
|
71
|
+
* @param client - Client to use
|
72
|
+
* @param parameters - {@link SimulateContractParameters}
|
73
|
+
* @returns The simulation result and write request. {@link SimulateContractReturnType}
|
74
|
+
*
|
75
|
+
* @example
|
76
|
+
* import { createPublicClient, http } from 'viem'
|
77
|
+
* import { mainnet } from 'viem/chains'
|
78
|
+
* import { simulateContract } from 'viem/contract'
|
79
|
+
*
|
80
|
+
* const client = createPublicClient({
|
81
|
+
* chain: mainnet,
|
82
|
+
* transport: http(),
|
83
|
+
* })
|
84
|
+
* const results = await simulateContract(client, {
|
85
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
86
|
+
* abi: parseAbi(['function mint(uint32) view returns (uint32)']),
|
87
|
+
* functionName: 'mint',
|
88
|
+
* args: ['69420'],
|
89
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
90
|
+
* })
|
91
|
+
*/
|
60
92
|
export async function simulateContract<
|
61
93
|
TChain extends Chain | undefined,
|
62
94
|
TAbi extends Abi | readonly unknown[],
|
@@ -6,14 +6,39 @@ export type UninstallFilterParameters = {
|
|
6
6
|
}
|
7
7
|
export type UninstallFilterReturnType = boolean
|
8
8
|
|
9
|
+
/**
|
10
|
+
* Destroys a [`Filter`](https://viem.sh/docs/glossary/types.html#filter).
|
11
|
+
*
|
12
|
+
* - Docs: https://viem.sh/docs/actions/public/uninstallFilter.html
|
13
|
+
* - JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)
|
14
|
+
*
|
15
|
+
* @remarks
|
16
|
+
* Destroys a Filter that was created from one of the following Actions:
|
17
|
+
* - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
18
|
+
* - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
19
|
+
* - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
20
|
+
*
|
21
|
+
* @param client - Client to use
|
22
|
+
* @param parameters - {@link UninstallFilterParameters}
|
23
|
+
* @returns A boolean indicating if the Filter was successfully uninstalled. {@link UninstallFilterReturnType}
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
* import { createPublicClient, http } from 'viem'
|
27
|
+
* import { mainnet } from 'viem/chains'
|
28
|
+
* import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'
|
29
|
+
*
|
30
|
+
* const filter = await createPendingTransactionFilter(client)
|
31
|
+
* const uninstalled = await uninstallFilter(client, { filter })
|
32
|
+
* // true
|
33
|
+
*/
|
9
34
|
export async function uninstallFilter<
|
10
35
|
TTransport extends Transport,
|
11
36
|
TChain extends Chain | undefined,
|
12
37
|
>(
|
13
|
-
|
38
|
+
_client: PublicClient<TTransport, TChain>,
|
14
39
|
{ filter }: UninstallFilterParameters,
|
15
40
|
): Promise<UninstallFilterReturnType> {
|
16
|
-
return
|
41
|
+
return filter.request({
|
17
42
|
method: 'eth_uninstallFilter',
|
18
43
|
params: [filter.id],
|
19
44
|
})
|
@@ -30,17 +30,63 @@ export type WaitForTransactionReceiptReturnType<
|
|
30
30
|
export type WaitForTransactionReceiptParameters<
|
31
31
|
TChain extends Chain | undefined = Chain | undefined,
|
32
32
|
> = {
|
33
|
-
/**
|
33
|
+
/**
|
34
|
+
* The number of confirmations (blocks that have passed) to wait before resolving.
|
35
|
+
* @default 1
|
36
|
+
*/
|
34
37
|
confirmations?: number
|
35
38
|
/** The hash of the transaction. */
|
36
39
|
hash: Hash
|
40
|
+
/** Optional callback to emit if the transaction has been replaced. */
|
37
41
|
onReplaced?: (response: ReplacementReturnType<TChain>) => void
|
38
|
-
/**
|
42
|
+
/**
|
43
|
+
* Polling frequency (in ms). Defaults to the client's pollingInterval config.
|
44
|
+
* @default client.pollingInterval
|
45
|
+
*/
|
39
46
|
pollingInterval?: number
|
40
47
|
/** Optional timeout (in milliseconds) to wait before stopping polling. */
|
41
48
|
timeout?: number
|
42
49
|
}
|
43
50
|
|
51
|
+
/**
|
52
|
+
* Waits for the [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) to be included on a [Block](https://viem.sh/docs/glossary/terms.html#block) (one confirmation), and then returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms.html#transaction-receipt). If the Transaction reverts, then the action will throw an error.
|
53
|
+
*
|
54
|
+
* - Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt.html
|
55
|
+
* - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
|
56
|
+
* - JSON-RPC Methods:
|
57
|
+
* - Polls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt) on each block until it has been processed.
|
58
|
+
* - If a Transaction has been replaced:
|
59
|
+
* - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) and extracts the transactions
|
60
|
+
* - Checks if one of the Transactions is a replacement
|
61
|
+
* - If so, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).
|
62
|
+
*
|
63
|
+
* @remarks
|
64
|
+
* The `waitForTransactionReceipt` action additionally supports Replacement detection (e.g. sped up Transactions).
|
65
|
+
*
|
66
|
+
* Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel). Transactions are replaced when they are sent from the same nonce.
|
67
|
+
*
|
68
|
+
* There are 3 types of Transaction Replacement reasons:
|
69
|
+
*
|
70
|
+
* - `repriced`: The gas price has been modified (e.g. different `maxFeePerGas`)
|
71
|
+
* - `cancelled`: The Transaction has been cancelled (e.g. `value === 0n`)
|
72
|
+
* - `replaced`: The Transaction has been replaced (e.g. different `value` or `data`)
|
73
|
+
*
|
74
|
+
* @param client - Client to use
|
75
|
+
* @param parameters - {@link WaitForTransactionReceiptParameters}
|
76
|
+
* @returns The transaction receipt. {@link WaitForTransactionReceiptReturnType}
|
77
|
+
*
|
78
|
+
* @example
|
79
|
+
* import { createPublicClient, waitForTransactionReceipt, http } from 'viem'
|
80
|
+
* import { mainnet } from 'viem/chains'
|
81
|
+
*
|
82
|
+
* const client = createPublicClient({
|
83
|
+
* chain: mainnet,
|
84
|
+
* transport: http(),
|
85
|
+
* })
|
86
|
+
* const transactionReceipt = await waitForTransactionReceipt(client, {
|
87
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
88
|
+
* })
|
89
|
+
*/
|
44
90
|
export async function waitForTransactionReceipt<
|
45
91
|
TChain extends Chain | undefined,
|
46
92
|
>(
|
@@ -42,7 +42,31 @@ export type WatchBlockNumberParameters<
|
|
42
42
|
|
43
43
|
export type WatchBlockNumberReturnType = () => void
|
44
44
|
|
45
|
-
/**
|
45
|
+
/**
|
46
|
+
* Watches and returns incoming block numbers.
|
47
|
+
*
|
48
|
+
* - Docs: https://viem.sh/docs/actions/public/watchBlockNumber.html
|
49
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/watching-blocks
|
50
|
+
* - JSON-RPC Methods:
|
51
|
+
* - When `poll: true`, calls [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber) on a polling interval.
|
52
|
+
* - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `"newHeads"` event.
|
53
|
+
*
|
54
|
+
* @param client - Client to use
|
55
|
+
* @param parameters - {@link WatchBlockNumberParameters}
|
56
|
+
* @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlockNumberReturnType}
|
57
|
+
*
|
58
|
+
* @example
|
59
|
+
* import { createPublicClient, watchBlockNumber, http } from 'viem'
|
60
|
+
* import { mainnet } from 'viem/chains'
|
61
|
+
*
|
62
|
+
* const client = createPublicClient({
|
63
|
+
* chain: mainnet,
|
64
|
+
* transport: http(),
|
65
|
+
* })
|
66
|
+
* const unwatch = await watchBlockNumber(client, {
|
67
|
+
* onBlockNumber: (blockNumber) => console.log(blockNumber),
|
68
|
+
* })
|
69
|
+
*/
|
46
70
|
export function watchBlockNumber<
|
47
71
|
TChain extends Chain | undefined,
|
48
72
|
TTransport extends Transport,
|
@@ -45,13 +45,35 @@ export type WatchBlocksParameters<
|
|
45
45
|
poll?: false
|
46
46
|
pollingInterval?: never
|
47
47
|
}
|
48
|
-
| (PollOptions & { poll
|
48
|
+
| (PollOptions & { poll?: true })
|
49
49
|
: PollOptions & { poll?: true })
|
50
50
|
|
51
51
|
export type WatchBlocksReturnType = () => void
|
52
52
|
|
53
53
|
/**
|
54
|
-
*
|
54
|
+
* Watches and returns information for incoming blocks.
|
55
|
+
*
|
56
|
+
* - Docs: https://viem.sh/docs/actions/public/watchBlocks.html
|
57
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/watching-blocks
|
58
|
+
* - JSON-RPC Methods:
|
59
|
+
* - When `poll: true`, calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getBlockByNumber) on a polling interval.
|
60
|
+
* - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `"newHeads"` event.
|
61
|
+
*
|
62
|
+
* @param client - Client to use
|
63
|
+
* @param parameters - {@link WatchBlocksParameters}
|
64
|
+
* @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlocksReturnType}
|
65
|
+
*
|
66
|
+
* @example
|
67
|
+
* import { createPublicClient, watchBlocks, http } from 'viem'
|
68
|
+
* import { mainnet } from 'viem/chains'
|
69
|
+
*
|
70
|
+
* const client = createPublicClient({
|
71
|
+
* chain: mainnet,
|
72
|
+
* transport: http(),
|
73
|
+
* })
|
74
|
+
* const unwatch = await watchBlocks(client, {
|
75
|
+
* onBlock: (block) => console.log(block),
|
76
|
+
* })
|
55
77
|
*/
|
56
78
|
export function watchBlocks<
|
57
79
|
TTransport extends Transport,
|
@@ -54,6 +54,37 @@ export type WatchContractEventParameters<
|
|
54
54
|
|
55
55
|
export type WatchContractEventReturnType = () => void
|
56
56
|
|
57
|
+
/**
|
58
|
+
* Watches and returns emitted contract event logs.
|
59
|
+
*
|
60
|
+
* - Docs: https://viem.sh/docs/contract/watchContractEvent.html
|
61
|
+
*
|
62
|
+
* @remarks
|
63
|
+
* This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent.html#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent.html#onLogs).
|
64
|
+
*
|
65
|
+
* `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
|
66
|
+
*
|
67
|
+
* @param client - Client to use
|
68
|
+
* @param parameters - {@link WatchContractEventParameters}
|
69
|
+
* @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}
|
70
|
+
*
|
71
|
+
* @example
|
72
|
+
* import { createPublicClient, http, parseAbi } from 'viem'
|
73
|
+
* import { mainnet } from 'viem/chains'
|
74
|
+
* import { watchContractEvent } from 'viem/contract'
|
75
|
+
*
|
76
|
+
* const client = createPublicClient({
|
77
|
+
* chain: mainnet,
|
78
|
+
* transport: http(),
|
79
|
+
* })
|
80
|
+
* const unwatch = watchContractEvent(client, {
|
81
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
82
|
+
* abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),
|
83
|
+
* eventName: 'Transfer',
|
84
|
+
* args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },
|
85
|
+
* onLogs: (logs) => console.log(logs),
|
86
|
+
* })
|
87
|
+
*/
|
57
88
|
export function watchContractEvent<
|
58
89
|
TChain extends Chain | undefined,
|
59
90
|
TAbi extends Abi | readonly unknown[],
|
@@ -32,7 +32,10 @@ export type WatchEventParameters<
|
|
32
32
|
> = {
|
33
33
|
/** The address of the contract. */
|
34
34
|
address?: Address | Address[]
|
35
|
-
/**
|
35
|
+
/**
|
36
|
+
* Whether or not the event logs should be batched on each invocation.
|
37
|
+
* @default true
|
38
|
+
*/
|
36
39
|
batch?: boolean
|
37
40
|
/** The callback to call when an error occurred when trying to get for a new block. */
|
38
41
|
onError?: (error: Error) => void
|
@@ -53,6 +56,39 @@ export type WatchEventParameters<
|
|
53
56
|
|
54
57
|
export type WatchEventReturnType = () => void
|
55
58
|
|
59
|
+
/**
|
60
|
+
* Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms#event-log).
|
61
|
+
*
|
62
|
+
* - Docs: https://viem.sh/docs/actions/public/watchEvent.html
|
63
|
+
* - JSON-RPC Methods:
|
64
|
+
* - **RPC Provider supports `eth_newFilter`:**
|
65
|
+
* - Calls [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter) to create a filter (called on initialize).
|
66
|
+
* - On a polling interval, it will call [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges).
|
67
|
+
* - **RPC Provider does not support `eth_newFilter`:**
|
68
|
+
* - Calls [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs) for each block between the polling interval.
|
69
|
+
*
|
70
|
+
* @remarks
|
71
|
+
* This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent.html#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent.html#onLogs).
|
72
|
+
*
|
73
|
+
* `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter.html) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.
|
74
|
+
*
|
75
|
+
* @param client - Client to use
|
76
|
+
* @param parameters - {@link WatchEventParameters}
|
77
|
+
* @returns A function that can be invoked to stop watching for new Event Logs. {@link WatchEventReturnType}
|
78
|
+
*
|
79
|
+
* @example
|
80
|
+
* import { createPublicClient, http } from 'viem'
|
81
|
+
* import { mainnet } from 'viem/chains'
|
82
|
+
* import { watchEvent } from 'viem/public'
|
83
|
+
*
|
84
|
+
* const client = createPublicClient({
|
85
|
+
* chain: mainnet,
|
86
|
+
* transport: http(),
|
87
|
+
* })
|
88
|
+
* const unwatch = watchEvent(client, {
|
89
|
+
* onLogs: (logs) => console.log(logs),
|
90
|
+
* })
|
91
|
+
*/
|
56
92
|
export function watchEvent<
|
57
93
|
TChain extends Chain | undefined,
|
58
94
|
TAbiEvent extends AbiEvent | undefined,
|
@@ -15,9 +15,15 @@ export type OnTransactionsParameter = Hash[]
|
|
15
15
|
export type OnTransactionsFn = (transactions: OnTransactionsParameter) => void
|
16
16
|
|
17
17
|
type PollOptions = {
|
18
|
-
/**
|
18
|
+
/**
|
19
|
+
* Whether or not the transaction hashes should be batched on each invocation.
|
20
|
+
* @default true
|
21
|
+
*/
|
19
22
|
batch?: boolean
|
20
|
-
/**
|
23
|
+
/**
|
24
|
+
* Polling frequency (in ms). Defaults to Client's pollingInterval config.
|
25
|
+
* @default client.pollingInterval
|
26
|
+
*/
|
21
27
|
pollingInterval?: number
|
22
28
|
}
|
23
29
|
|
@@ -32,17 +38,56 @@ export type WatchPendingTransactionsParameters<
|
|
32
38
|
?
|
33
39
|
| {
|
34
40
|
batch?: never
|
35
|
-
/**
|
41
|
+
/**
|
42
|
+
* Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`.
|
43
|
+
* @default false
|
44
|
+
*/
|
36
45
|
poll?: false
|
37
46
|
pollingInterval?: never
|
38
47
|
}
|
39
|
-
| (PollOptions & {
|
48
|
+
| (PollOptions & {
|
49
|
+
/**
|
50
|
+
* Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`.
|
51
|
+
* @default true
|
52
|
+
*/
|
53
|
+
poll?: true
|
54
|
+
})
|
40
55
|
: PollOptions & {
|
41
56
|
poll?: true
|
42
57
|
})
|
43
58
|
|
44
59
|
export type WatchPendingTransactionsReturnType = () => void
|
45
60
|
|
61
|
+
/**
|
62
|
+
* Watches and returns pending transaction hashes.
|
63
|
+
*
|
64
|
+
* - Docs: https://viem.sh/docs/actions/public/watchPendingTransactions.html
|
65
|
+
* - JSON-RPC Methods:
|
66
|
+
* - When `poll: true`
|
67
|
+
* - Calls [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter) to initialize the filter.
|
68
|
+
* - Calls [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getFilterChanges) on a polling interval.
|
69
|
+
* - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `"newPendingTransactions"` event.
|
70
|
+
*
|
71
|
+
* @remarks
|
72
|
+
* This Action will batch up all the pending transactions found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchPendingTransactions.html#pollinginterval-optional), and invoke them via [`onTransactions`](https://viem.sh/docs/actions/public/watchPendingTransactions.html#ontransactions).
|
73
|
+
*
|
74
|
+
* @param client - Client to use
|
75
|
+
* @param parameters - {@link WatchPendingTransactionsParameters}
|
76
|
+
* @returns A function that can be invoked to stop watching for new pending transaction hashes. {@link WatchPendingTransactionsReturnType}
|
77
|
+
*
|
78
|
+
* @example
|
79
|
+
* import { createPublicClient, http } from 'viem'
|
80
|
+
* import { mainnet } from 'viem/chains'
|
81
|
+
* import { watchPendingTransactions } from 'viem/public'
|
82
|
+
*
|
83
|
+
* const client = createPublicClient({
|
84
|
+
* chain: mainnet,
|
85
|
+
* transport: http(),
|
86
|
+
* })
|
87
|
+
* const unwatch = await watchPendingTransactions(client, {
|
88
|
+
* onTransactions: (hashes) => console.log(hashes),
|
89
|
+
* })
|
90
|
+
*/
|
46
91
|
export function watchPendingTransactions<
|
47
92
|
TTransport extends Transport,
|
48
93
|
TChain extends Chain | undefined,
|
@@ -30,6 +30,33 @@ export type DeployContractParameters<
|
|
30
30
|
|
31
31
|
export type DeployContractReturnType = SendTransactionReturnType
|
32
32
|
|
33
|
+
/**
|
34
|
+
* Deploys a contract to the network, given bytecode and constructor arguments.
|
35
|
+
*
|
36
|
+
* - Docs: https://viem.sh/docs/contract/deployContract.html
|
37
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts
|
38
|
+
*
|
39
|
+
* @param client - Client to use
|
40
|
+
* @param parameters - {@link DeployContractParameters}
|
41
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* import { createWalletClient, http } from 'viem'
|
45
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
46
|
+
* import { mainnet } from 'viem/chains'
|
47
|
+
* import { deployContract } from 'viem/contract'
|
48
|
+
*
|
49
|
+
* const client = createWalletClient({
|
50
|
+
* account = privateKeyToAccount('0x…'),
|
51
|
+
* chain: mainnet,
|
52
|
+
* transport: http(),
|
53
|
+
* })
|
54
|
+
* const hash = await deployContract(client, {
|
55
|
+
* abi: [],
|
56
|
+
* account: '0x…,
|
57
|
+
* bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
|
58
|
+
* })
|
59
|
+
*/
|
33
60
|
export function deployContract<
|
34
61
|
TAbi extends Abi | readonly unknown[],
|
35
62
|
TChain extends Chain | undefined,
|