@aastar/sdk 0.16.11 → 0.16.14
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/README.md +100 -128
- package/dist/clients/ExperimentClient.d.ts +34 -0
- package/{packages/sdk/src/clients/ExperimentClient.ts → dist/clients/ExperimentClient.js} +11 -33
- package/dist/clients/ExperimentClient.test.d.ts +1 -0
- package/dist/clients/ExperimentClient.test.js +53 -0
- package/dist/clients/admin.d.ts +11 -0
- package/dist/clients/admin.js +20 -0
- package/dist/clients/admin.test.d.ts +1 -0
- package/dist/clients/admin.test.js +79 -0
- package/dist/clients/clients.test.d.ts +1 -0
- package/dist/clients/clients.test.js +91 -0
- package/dist/clients/community.d.ts +40 -0
- package/{packages/sdk/src/clients/community.ts → dist/clients/community.js} +86 -189
- package/dist/clients/community.test.d.ts +1 -0
- package/dist/clients/community.test.js +99 -0
- package/dist/clients/endUser.d.ts +77 -0
- package/dist/clients/endUser.js +298 -0
- package/dist/clients/endUser.test.d.ts +1 -0
- package/dist/clients/endUser.test.js +188 -0
- package/dist/clients/operator.d.ts +66 -0
- package/{packages/sdk/src/clients/operator.ts → dist/clients/operator.js} +66 -137
- package/dist/clients/operator.test.d.ts +1 -0
- package/dist/clients/operator.test.js +139 -0
- package/dist/core/src/abis/BLSAggregator.json +686 -0
- package/dist/core/src/abis/BLSValidator.json +42 -0
- package/dist/core/src/abis/DVTValidator.json +368 -0
- package/dist/core/src/abis/EntryPoint.json +1382 -0
- package/dist/core/src/abis/GToken.json +513 -0
- package/dist/core/src/abis/GTokenStaking.json +949 -0
- package/dist/core/src/abis/MySBT.json +1518 -0
- package/dist/core/src/abis/Paymaster.json +1143 -0
- package/dist/core/src/abis/PaymasterFactory.json +640 -0
- package/dist/core/src/abis/Registry.json +1942 -0
- package/dist/core/src/abis/ReputationSystem.json +699 -0
- package/dist/core/src/abis/SimpleAccount.json +560 -0
- package/dist/core/src/abis/SimpleAccountFactory.json +111 -0
- package/dist/core/src/abis/SuperPaymaster.json +1781 -0
- package/dist/core/src/abis/xPNTsFactory.json +718 -0
- package/dist/core/src/abis/xPNTsToken.json +1280 -0
- package/dist/errors/AAStarError.d.ts +26 -0
- package/dist/errors/AAStarError.js +32 -0
- package/dist/errors/AAStarError.test.d.ts +1 -0
- package/dist/errors/AAStarError.test.js +74 -0
- package/dist/errors/decoder.d.ts +6 -0
- package/{packages/sdk/src/errors/decoder.ts → dist/errors/decoder.js} +15 -19
- package/dist/errors/decoder.test.d.ts +1 -0
- package/dist/errors/decoder.test.js +90 -0
- package/dist/index.d.ts +18 -0
- package/{packages/sdk/src/index.ts → dist/index.js} +0 -3
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.js +7 -0
- package/dist/types/result.d.ts +15 -0
- package/dist/types/result.js +23 -0
- package/dist/utils/errorHandler.d.ts +40 -0
- package/{packages/sdk/src/utils/errorHandler.ts → dist/utils/errorHandler.js} +22 -75
- package/dist/utils/errorHandler.test.d.ts +1 -0
- package/dist/utils/errorHandler.test.js +89 -0
- package/dist/utils/eventDecoder.d.ts +7 -0
- package/dist/utils/eventDecoder.js +54 -0
- package/dist/utils/eventDecoder.test.d.ts +1 -0
- package/dist/utils/eventDecoder.test.js +48 -0
- package/dist/utils/funding.d.ts +115 -0
- package/{packages/sdk/src/utils/funding.ts → dist/utils/funding.js} +27 -119
- package/dist/utils/funding.test.d.ts +1 -0
- package/dist/utils/funding.test.js +105 -0
- package/dist/utils/keys.d.ts +61 -0
- package/{packages/sdk/src/utils/keys.ts → dist/utils/keys.js} +15 -44
- package/dist/utils/keys.test.d.ts +1 -0
- package/dist/utils/keys.test.js +81 -0
- package/dist/utils/roleData.d.ts +66 -0
- package/{packages/sdk/src/utils/roleData.ts → dist/utils/roleData.js} +34 -57
- package/dist/utils/roleData.test.d.ts +1 -0
- package/dist/utils/roleData.test.js +74 -0
- package/dist/utils/testScenarios.d.ts +33 -0
- package/dist/utils/testScenarios.js +85 -0
- package/dist/utils/testScenarios.test.d.ts +1 -0
- package/dist/utils/testScenarios.test.js +68 -0
- package/dist/utils/userOp.d.ts +78 -0
- package/{packages/sdk/src/utils/userOp.ts → dist/utils/userOp.js} +59 -126
- package/dist/utils/userOp.test.d.ts +1 -0
- package/dist/utils/userOp.test.js +152 -0
- package/package.json +25 -61
- package/.github/workflows/gas-analytics-daily.yml +0 -52
- package/.gitmodules +0 -9
- package/CHANGELOG.md +0 -43
- package/aastar-sdk.code-workspace +0 -14
- package/abis/BLSAggregator.json +0 -572
- package/abis/BLSValidator.json +0 -39
- package/abis/DVTValidator.json +0 -383
- package/abis/Eip7702Support.json +0 -24
- package/abis/EntryPoint.json +0 -1379
- package/abis/GToken.json +0 -510
- package/abis/GTokenStaking.json +0 -918
- package/abis/LegacyAccount.json +0 -625
- package/abis/MySBT.json +0 -1547
- package/abis/Paymaster.json +0 -1192
- package/abis/PaymasterFactory.json +0 -637
- package/abis/PaymasterV4_2.json +0 -1193
- package/abis/Registry.json +0 -1677
- package/abis/ReputationSystem.json +0 -659
- package/abis/SenderCreator.json +0 -99
- package/abis/Simple7702Account.json +0 -395
- package/abis/SimpleAccount.json +0 -625
- package/abis/SimpleAccountFactory.json +0 -108
- package/abis/SimpleAccountFactoryV08.json +0 -87
- package/abis/SimpleAccountV08.json +0 -557
- package/abis/SuperPaymaster.json +0 -1568
- package/abis/UserOperationLib.json +0 -57
- package/abis/aPNTs.json +0 -1160
- package/abis/xPNTsFactory.json +0 -715
- package/abis/xPNTsToken.json +0 -1160
- package/backup/run_sdk_regression.sh +0 -135
- package/config/networks/README.md +0 -54
- package/config/networks/mainnet.env.example +0 -39
- package/config/networks/optimism-sepolia.env.example +0 -35
- package/config/networks/optimism.env.example +0 -36
- package/config/networks/sepolia.env.example +0 -36
- package/config.anvil.json +0 -1
- package/config.sepolia.json +0 -19
- package/config.test.json +0 -27
- package/data/experiment_data.csv +0 -36
- package/data/industry_baseline_2025-12-23.json +0 -154
- package/data/industry_baseline_latest.json +0 -154
- package/docs/ABI_MAINTENANCE_PLAN.md +0 -132
- package/docs/API_REFERENCE.md +0 -796
- package/docs/Configuration_Sync.md +0 -47
- package/docs/DAO_Mining_Distribution_Plan.md +0 -522
- package/docs/DEMO_REFACTOR_PLAN.md +0 -289
- package/docs/DOCUMENTATION_PLAN.md +0 -455
- package/docs/ENV_SEPOLIA_UPDATE.md +0 -68
- package/docs/L2_BUSINESS_CLIENTS_PLAN.md +0 -394
- package/docs/L4_Manual_Test_CheatSheet.md +0 -172
- package/docs/Plan.md +0 -266
- package/docs/Regression_Testing_Guide.md +0 -70
- package/docs/Reputation-to-Credit_Mapping_Whitepaper.md +0 -242
- package/docs/SDK_ABI_COVERAGE.md +0 -839
- package/docs/SDK_COVERAGE_STRATEGY.md +0 -397
- package/docs/SDK_Optimization_Evaluation_Plan.md +0 -51
- package/docs/SDK_REGRESSION_AND_API_PLAN.md +0 -98
- package/docs/SDK_STAGE3_PLAN.md +0 -151
- package/docs/SEPOLIA_ENV_REFERENCE.md +0 -51
- package/docs/STAGE3.md +0 -191
- package/docs/Script_Comparison_Report.md +0 -91
- package/docs/Sepolia_Latest_Deployment.md +0 -117
- package/docs/TESTER_GUIDE_GASLESS.md +0 -409
- package/docs/TEST_COVERAGE_MATRIX.md +0 -72
- package/docs/TODO_SDK_COVERAGE.md +0 -55
- package/docs/USER_CASE_DESIGN.md +0 -110
- package/docs/Verifier_L4_Gasless_Plan.md +0 -454
- package/docs/api/@aastar/account/README.md +0 -15
- package/docs/api/@aastar/account/classes/UserOpClient.md +0 -87
- package/docs/api/@aastar/account/functions/createEOAWalletClient.md +0 -21
- package/docs/api/@aastar/account/functions/getUserOpHash.md +0 -23
- package/docs/api/@aastar/account/functions/packUserOpLimits.md +0 -19
- package/docs/api/@aastar/account/functions/toSimpleSmartAccount.md +0 -83
- package/docs/api/@aastar/account/type-aliases/EOAWalletClient.md +0 -37
- package/docs/api/@aastar/account/type-aliases/SimpleSmartAccount.md +0 -39
- package/docs/api/@aastar/core/README.md +0 -211
- package/docs/api/@aastar/core/classes/BLSSigner.md +0 -147
- package/docs/api/@aastar/core/classes/BaseClient.md +0 -9657
- package/docs/api/@aastar/core/classes/ContractConfigManager.md +0 -25
- package/docs/api/@aastar/core/classes/RequirementChecker.md +0 -1837
- package/docs/api/@aastar/core/classes/SepoliaFaucetAPI.md +0 -13661
- package/docs/api/@aastar/core/classes/StateValidator.md +0 -133
- package/docs/api/@aastar/core/enumerations/EntryPointVersion.md +0 -17
- package/docs/api/@aastar/core/enumerations/NodeType.md +0 -33
- package/docs/api/@aastar/core/enumerations/RolePermissionLevel.md +0 -43
- package/docs/api/@aastar/core/functions/accountActions.md +0 -2720
- package/docs/api/@aastar/core/functions/accountFactoryActions.md +0 -2720
- package/docs/api/@aastar/core/functions/aggregatorActions.md +0 -2720
- package/docs/api/@aastar/core/functions/createAAStarPublicClient.md +0 -3105
- package/docs/api/@aastar/core/functions/dvtActions.md +0 -2720
- package/docs/api/@aastar/core/functions/entryPointActions.md +0 -2724
- package/docs/api/@aastar/core/functions/gTokenActions.md +0 -2714
- package/docs/api/@aastar/core/functions/gTokenExtendedActions.md +0 -2720
- package/docs/api/@aastar/core/functions/getAddressUrl.md +0 -32
- package/docs/api/@aastar/core/functions/getAllCommunityConfigs.md +0 -9
- package/docs/api/@aastar/core/functions/getAllV2Contracts.md +0 -20
- package/docs/api/@aastar/core/functions/getBlockExplorer.md +0 -26
- package/docs/api/@aastar/core/functions/getChainId.md +0 -26
- package/docs/api/@aastar/core/functions/getCommunities.md +0 -76
- package/docs/api/@aastar/core/functions/getCommunity.md +0 -32
- package/docs/api/@aastar/core/functions/getCommunityConfig.md +0 -15
- package/docs/api/@aastar/core/functions/getContract.md +0 -37
- package/docs/api/@aastar/core/functions/getContractNetworks.md +0 -18
- package/docs/api/@aastar/core/functions/getContracts.md +0 -194
- package/docs/api/@aastar/core/functions/getCoreContracts.md +0 -71
- package/docs/api/@aastar/core/functions/getDeploymentDate.md +0 -32
- package/docs/api/@aastar/core/functions/getEntryPoint.md +0 -25
- package/docs/api/@aastar/core/functions/getNetwork.md +0 -26
- package/docs/api/@aastar/core/functions/getPaymasterV4_1.md +0 -25
- package/docs/api/@aastar/core/functions/getRoleName.md +0 -15
- package/docs/api/@aastar/core/functions/getRpcUrl.md +0 -25
- package/docs/api/@aastar/core/functions/getSimpleAccountFactory.md +0 -25
- package/docs/api/@aastar/core/functions/getSuperPaymasterV2.md +0 -25
- package/docs/api/@aastar/core/functions/getTestAccounts.md +0 -30
- package/docs/api/@aastar/core/functions/getTestTokenContracts.md +0 -38
- package/docs/api/@aastar/core/functions/getTokenContracts.md +0 -31
- package/docs/api/@aastar/core/functions/getTxUrl.md +0 -32
- package/docs/api/@aastar/core/functions/getV2ContractByAddress.md +0 -28
- package/docs/api/@aastar/core/functions/getV2ContractByName.md +0 -28
- package/docs/api/@aastar/core/functions/getV2ContractsByDate.md +0 -26
- package/docs/api/@aastar/core/functions/isContractNetworkSupported.md +0 -27
- package/docs/api/@aastar/core/functions/isRegisteredCommunity.md +0 -15
- package/docs/api/@aastar/core/functions/isV2Contract.md +0 -27
- package/docs/api/@aastar/core/functions/paymasterActions.md +0 -2720
- package/docs/api/@aastar/core/functions/paymasterFactoryActions.md +0 -2720
- package/docs/api/@aastar/core/functions/registryActions.md +0 -2720
- package/docs/api/@aastar/core/functions/reputationActions.md +0 -2720
- package/docs/api/@aastar/core/functions/sbtActions.md +0 -2720
- package/docs/api/@aastar/core/functions/stakingActions.md +0 -2720
- package/docs/api/@aastar/core/functions/superPaymasterActions.md +0 -2720
- package/docs/api/@aastar/core/functions/tokenActions.md +0 -2714
- package/docs/api/@aastar/core/functions/xPNTsFactoryActions.md +0 -2720
- package/docs/api/@aastar/core/interfaces/AccountBalance.md +0 -41
- package/docs/api/@aastar/core/interfaces/BalanceValidationParams.md +0 -51
- package/docs/api/@aastar/core/interfaces/ClientConfig.md +0 -4841
- package/docs/api/@aastar/core/interfaces/CommunityConfig.md +0 -81
- package/docs/api/@aastar/core/interfaces/ContractVersion.md +0 -63
- package/docs/api/@aastar/core/interfaces/DeploymentValidationParams.md +0 -39
- package/docs/api/@aastar/core/interfaces/RoleConfig.md +0 -83
- package/docs/api/@aastar/core/interfaces/RoleRequirement.md +0 -43
- package/docs/api/@aastar/core/interfaces/RoleValidationParams.md +0 -55
- package/docs/api/@aastar/core/interfaces/SuperPaymasterConfig.md +0 -57
- package/docs/api/@aastar/core/interfaces/TokenBalanceValidationParams.md +0 -63
- package/docs/api/@aastar/core/interfaces/TransactionOptions.md +0 -24
- package/docs/api/@aastar/core/interfaces/ValidationParams.md +0 -25
- package/docs/api/@aastar/core/interfaces/ValidationResult.md +0 -25
- package/docs/api/@aastar/core/type-aliases/AccountActions.md +0 -151
- package/docs/api/@aastar/core/type-aliases/AccountFactoryActions.md +0 -55
- package/docs/api/@aastar/core/type-aliases/AggregatorActions.md +0 -471
- package/docs/api/@aastar/core/type-aliases/BusinessResult.md +0 -12
- package/docs/api/@aastar/core/type-aliases/ContractCategory.md +0 -5
- package/docs/api/@aastar/core/type-aliases/ContractNetwork.md +0 -5
- package/docs/api/@aastar/core/type-aliases/DVTActions.md +0 -319
- package/docs/api/@aastar/core/type-aliases/EntryPointActions.md +0 -103
- package/docs/api/@aastar/core/type-aliases/GTokenExtendedActions.md +0 -239
- package/docs/api/@aastar/core/type-aliases/NetworkContracts.md +0 -5
- package/docs/api/@aastar/core/type-aliases/PaymasterActions.md +0 -1087
- package/docs/api/@aastar/core/type-aliases/PaymasterFactoryActions.md +0 -263
- package/docs/api/@aastar/core/type-aliases/RegistryActions.md +0 -1543
- package/docs/api/@aastar/core/type-aliases/ReputationActions.md +0 -811
- package/docs/api/@aastar/core/type-aliases/SBTActions.md +0 -1199
- package/docs/api/@aastar/core/type-aliases/StakingActions.md +0 -703
- package/docs/api/@aastar/core/type-aliases/SuperPaymasterActions.md +0 -1311
- package/docs/api/@aastar/core/type-aliases/SupportedNetwork.md +0 -3
- package/docs/api/@aastar/core/type-aliases/TokenActions.md +0 -1227
- package/docs/api/@aastar/core/type-aliases/XPNTsFactoryActions.md +0 -395
- package/docs/api/@aastar/core/variables/AASTAR_COMMUNITY.md +0 -8
- package/docs/api/@aastar/core/variables/ALL_ADDRESSES.md +0 -75
- package/docs/api/@aastar/core/variables/ALL_ROLES.md +0 -5
- package/docs/api/@aastar/core/variables/APNTS_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/BLSAggregatorABI.md +0 -3
- package/docs/api/@aastar/core/variables/BLSAggregatorArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/BLSHelpers.md +0 -101
- package/docs/api/@aastar/core/variables/BLSValidatorABI.md +0 -3
- package/docs/api/@aastar/core/variables/BLSValidatorArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/BLS_AGGREGATOR_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/BLS_VALIDATOR_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/BPS_DENOMINATOR.md +0 -5
- package/docs/api/@aastar/core/variables/BRANDING.md +0 -67
- package/docs/api/@aastar/core/variables/BREAD_COMMUNITY.md +0 -8
- package/docs/api/@aastar/core/variables/CHAIN_MAINNET.md +0 -3
- package/docs/api/@aastar/core/variables/CHAIN_SEPOLIA.md +0 -5
- package/docs/api/@aastar/core/variables/COMMUNITIES.md +0 -5
- package/docs/api/@aastar/core/variables/COMMUNITY_OWNERS.md +0 -15
- package/docs/api/@aastar/core/variables/CONTRACTS.md +0 -179
- package/docs/api/@aastar/core/variables/CONTRACT_METADATA.md +0 -67
- package/docs/api/@aastar/core/variables/CONTRACT_SRC_HASH.md +0 -5
- package/docs/api/@aastar/core/variables/CORE_ADDRESSES.md +0 -51
- package/docs/api/@aastar/core/variables/DEFAULT_ADMIN_ROLE.md +0 -17
- package/docs/api/@aastar/core/variables/DEFAULT_APNTS_PRICE_USD.md +0 -5
- package/docs/api/@aastar/core/variables/DEFAULT_CALL_GAS_LIMIT.md +0 -3
- package/docs/api/@aastar/core/variables/DEFAULT_GAS_TOKEN_MINT_AMOUNT.md +0 -5
- package/docs/api/@aastar/core/variables/DEFAULT_PRE_VERIFICATION_GAS.md +0 -3
- package/docs/api/@aastar/core/variables/DEFAULT_TIMEOUT_MS.md +0 -5
- package/docs/api/@aastar/core/variables/DEFAULT_TOKEN_NAME.md +0 -3
- package/docs/api/@aastar/core/variables/DEFAULT_TOKEN_SYMBOL.md +0 -5
- package/docs/api/@aastar/core/variables/DEFAULT_USDT_MINT_AMOUNT.md +0 -5
- package/docs/api/@aastar/core/variables/DEFAULT_VERIFICATION_GAS_LIMIT.md +0 -5
- package/docs/api/@aastar/core/variables/DVTValidatorABI.md +0 -3
- package/docs/api/@aastar/core/variables/DVTValidatorArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/DVT_VALIDATOR_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/ENTRY_POINT_0_8_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/ENTRY_POINT_0_9_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/ENTRY_POINT_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/EntryPointABI.md +0 -3
- package/docs/api/@aastar/core/variables/EntryPointArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/FAUCET_API_URL.md +0 -5
- package/docs/api/@aastar/core/variables/GTOKEN_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/GTOKEN_STAKING_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/GTokenABI.md +0 -3
- package/docs/api/@aastar/core/variables/GTokenArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/GTokenStakingABI.md +0 -3
- package/docs/api/@aastar/core/variables/GTokenStakingArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/INITIAL_ROLE_STAKES.md +0 -13
- package/docs/api/@aastar/core/variables/LINKS.md +0 -33
- package/docs/api/@aastar/core/variables/MAX_SERVICE_FEE.md +0 -5
- package/docs/api/@aastar/core/variables/MONITORING_ADDRESSES.md +0 -15
- package/docs/api/@aastar/core/variables/MySBTABI.md +0 -3
- package/docs/api/@aastar/core/variables/MySBTArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/NETWORKS.md +0 -79
- package/docs/api/@aastar/core/variables/NODE_STAKE_AMOUNTS.md +0 -31
- package/docs/api/@aastar/core/variables/OFFICIAL_ADDRESSES.md +0 -11
- package/docs/api/@aastar/core/variables/PAYMASTER_ADDRESSES.md +0 -15
- package/docs/api/@aastar/core/variables/PAYMASTER_FACTORY_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/PAYMASTER_V4_IMPL_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/PaymasterABI.md +0 -3
- package/docs/api/@aastar/core/variables/PaymasterArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/PaymasterFactoryABI.md +0 -3
- package/docs/api/@aastar/core/variables/PaymasterFactoryArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/PaymasterV4ABI.md +0 -3
- package/docs/api/@aastar/core/variables/PaymasterV4Artifact.md +0 -13
- package/docs/api/@aastar/core/variables/REGISTRY_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/REPUTATION_SYSTEM_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/ROLE_ANODE.md +0 -29
- package/docs/api/@aastar/core/variables/ROLE_COMMUNITY.md +0 -29
- package/docs/api/@aastar/core/variables/ROLE_DVT.md +0 -29
- package/docs/api/@aastar/core/variables/ROLE_ENDUSER.md +0 -33
- package/docs/api/@aastar/core/variables/ROLE_KMS.md +0 -29
- package/docs/api/@aastar/core/variables/ROLE_NAMES.md +0 -3
- package/docs/api/@aastar/core/variables/ROLE_PAYMASTER_AOA.md +0 -29
- package/docs/api/@aastar/core/variables/ROLE_PAYMASTER_SUPER.md +0 -33
- package/docs/api/@aastar/core/variables/ROLE_PERMISSION_LEVELS.md +0 -3
- package/docs/api/@aastar/core/variables/RegistryABI.md +0 -3
- package/docs/api/@aastar/core/variables/RegistryArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/ReputationSystemABI.md +0 -3
- package/docs/api/@aastar/core/variables/ReputationSystemArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/SBT_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/SEPOLIA_CONTRACTS.md +0 -175
- package/docs/api/@aastar/core/variables/SEPOLIA_V2_VERSIONS.md +0 -67
- package/docs/api/@aastar/core/variables/SERVICE_FEE_RATE.md +0 -5
- package/docs/api/@aastar/core/variables/SUPER_PAYMASTER_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/SimpleAccountABI.md +0 -3
- package/docs/api/@aastar/core/variables/SimpleAccountArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/SimpleAccountFactoryABI.md +0 -3
- package/docs/api/@aastar/core/variables/SimpleAccountFactoryArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/SuperPaymasterABI.md +0 -3
- package/docs/api/@aastar/core/variables/SuperPaymasterArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/TEST_ACCOUNT_ADDRESSES.md +0 -11
- package/docs/api/@aastar/core/variables/TEST_ACCOUNT_POOL_SIZE.md +0 -5
- package/docs/api/@aastar/core/variables/TEST_COMMUNITIES.md +0 -19
- package/docs/api/@aastar/core/variables/TEST_TOKEN_ADDRESSES.md +0 -19
- package/docs/api/@aastar/core/variables/TOKEN_ADDRESSES.md +0 -11
- package/docs/api/@aastar/core/variables/V2_SUMMARY.md +0 -39
- package/docs/api/@aastar/core/variables/XPNTS_FACTORY_ADDRESS.md +0 -3
- package/docs/api/@aastar/core/variables/xPNTsFactoryABI.md +0 -3
- package/docs/api/@aastar/core/variables/xPNTsFactoryArtifact.md +0 -13
- package/docs/api/@aastar/core/variables/xPNTsTokenABI.md +0 -3
- package/docs/api/@aastar/core/variables/xPNTsTokenArtifact.md +0 -13
- package/docs/api/@aastar/paymaster/README.md +0 -23
- package/docs/api/@aastar/paymaster/classes/PaymasterClient.md +0 -388
- package/docs/api/@aastar/paymaster/classes/PaymasterOperator.md +0 -451
- package/docs/api/@aastar/paymaster/classes/SuperPaymasterAdminClient.md +0 -189
- package/docs/api/@aastar/paymaster/classes/SuperPaymasterClient.md +0 -55
- package/docs/api/@aastar/paymaster/functions/buildPaymasterData.md +0 -34
- package/docs/api/@aastar/paymaster/functions/buildSuperPaymasterData.md +0 -30
- package/docs/api/@aastar/paymaster/functions/checkEligibility.md +0 -28
- package/docs/api/@aastar/paymaster/functions/formatUserOpV07.md +0 -15
- package/docs/api/@aastar/paymaster/functions/getPaymasterV4Middleware.md +0 -32
- package/docs/api/@aastar/paymaster/functions/getSuperPaymasterMiddleware.md +0 -32
- package/docs/api/@aastar/paymaster/functions/getUserOpHashV07.md +0 -21
- package/docs/api/@aastar/paymaster/type-aliases/GaslessReadinessReport.md +0 -55
- package/docs/api/@aastar/paymaster/type-aliases/GaslessTransactionConfig.md +0 -59
- package/docs/api/@aastar/paymaster/type-aliases/PaymasterConfig.md +0 -43
- package/docs/api/@aastar/paymaster/type-aliases/PaymasterV4MiddlewareConfig.md +0 -35
- package/docs/api/@aastar/tokens/README.md +0 -3
- package/docs/api/@aastar/tokens/classes/FinanceClient.md +0 -10385
- package/docs/api/README.md +0 -6
- package/docs/examples/community-flow.md +0 -28
- package/docs/examples/enduser-flow.md +0 -24
- package/docs/examples/index.md +0 -18
- package/docs/examples/multi-chain.md +0 -31
- package/docs/examples/operator-flow.md +0 -28
- package/docs/guide/CLI_GUIDE.md +0 -65
- package/docs/guide/DOCUMENTATION_PLAN.md +0 -455
- package/docs/guide/Security-solution.md +0 -106
- package/docs/guide/TEST_COMMANDS.md +0 -320
- package/docs/guide/getting-started.md +0 -133
- package/docs/guide/installation.md +0 -40
- package/docs/guide/paper-data-collection.md +0 -69
- package/docs/guide/quick-start.md +0 -52
- package/docs/guide/task_breakdown.md +0 -121
- package/docs/old-solution.md +0 -1078
- package/docs/paper-data-collection.md +0 -69
- package/docs/technical_plan.md +0 -510
- package/docs/zh/examples/community-flow.md +0 -38
- package/docs/zh/examples/complete-workflow.md +0 -10
- package/docs/zh/examples/enduser-flow.md +0 -33
- package/docs/zh/examples/index.md +0 -18
- package/docs/zh/examples/multi-chain.md +0 -46
- package/docs/zh/examples/operator-flow.md +0 -37
- package/docs/zh/guide/CLI_GUIDE.md +0 -48
- package/docs/zh/guide/DOCUMENTATION_PLAN.md +0 -455
- package/docs/zh/guide/Plan.md +0 -266
- package/docs/zh/guide/SDK_Optimization_Evaluation_Plan.md +0 -51
- package/docs/zh/guide/Security-solution.md +0 -106
- package/docs/zh/guide/TEST_COMMANDS.md +0 -125
- package/docs/zh/guide/TEST_COVERAGE_MATRIX.md +0 -72
- package/docs/zh/guide/concepts/account-abstraction.md +0 -95
- package/docs/zh/guide/concepts/rainbow-bridge.md +0 -68
- package/docs/zh/guide/concepts/reputation.md +0 -95
- package/docs/zh/guide/concepts/superpaymaster.md +0 -141
- package/docs/zh/guide/getting-started.md +0 -133
- package/docs/zh/guide/installation.md +0 -107
- package/docs/zh/guide/old-solution.md +0 -1078
- package/docs/zh/guide/paper-data-collection.md +0 -69
- package/docs/zh/guide/quick-start.md +0 -134
- package/docs/zh/guide/sdk-readme.md +0 -253
- package/docs/zh/guide/task_breakdown.md +0 -76
- package/docs/zh/guide/technical_plan.md +0 -510
- package/docs/zh/guide/use-cases/community-management.md +0 -141
- package/docs/zh/guide/use-cases/gasless-transactions.md +0 -71
- package/docs/zh/guide/use-cases/operator-staking.md +0 -84
- package/docs/zh/guide/use-cases/yop.md +0 -72
- package/env.template +0 -30
- package/examples/l1-api-demo.ts +0 -273
- package/examples/l2-clients-demo.ts +0 -135
- package/examples/l3-community-launch.ts +0 -49
- package/examples/l3-user-onboarding.ts +0 -56
- package/examples/prepare-gasless.ts +0 -89
- package/examples/sdk-demo/DEVELOPER_GUIDE.md +0 -159
- package/examples/sdk-demo/README.md +0 -30
- package/examples/sdk-demo/usage.ts +0 -137
- package/examples/simple-gasless-demo.ts +0 -109
- package/examples/simple-superpaymaster-demo.ts +0 -96
- package/ext/aastar-shared-config/.env.example +0 -6
- package/ext/aastar-shared-config/.github/workflows/check-secrets.yml +0 -257
- package/ext/aastar-shared-config/AGENTS.md +0 -21
- package/ext/aastar-shared-config/CHANGELOG.md +0 -99
- package/ext/aastar-shared-config/LICENSE +0 -21
- package/ext/aastar-shared-config/QUICK_START.md +0 -215
- package/ext/aastar-shared-config/README.md +0 -412
- package/ext/aastar-shared-config/SHARED_CONFIG_SUMMARY.md +0 -273
- package/ext/aastar-shared-config/check-locker-status.mjs +0 -7
- package/ext/aastar-shared-config/favicon.ico +0 -0
- package/ext/aastar-shared-config/generate-comparison-table.sh +0 -67
- package/ext/aastar-shared-config/package.json +0 -46
- package/ext/aastar-shared-config/pnpm-lock.yaml +0 -1182
- package/ext/aastar-shared-config/src/abis/BLSAggregator.json +0 -1
- package/ext/aastar-shared-config/src/abis/DVTValidator.json +0 -1
- package/ext/aastar-shared-config/src/abis/GToken.json +0 -1
- package/ext/aastar-shared-config/src/abis/GTokenStaking.json +0 -1
- package/ext/aastar-shared-config/src/abis/MySBT.json +0 -1
- package/ext/aastar-shared-config/src/abis/PaymasterFactory.json +0 -1
- package/ext/aastar-shared-config/src/abis/PaymasterV4.json +0 -1098
- package/ext/aastar-shared-config/src/abis/Registry.json +0 -1
- package/ext/aastar-shared-config/src/abis/SimpleAccount.json +0 -557
- package/ext/aastar-shared-config/src/abis/SimpleAccountFactory.json +0 -87
- package/ext/aastar-shared-config/src/abis/SuperPaymasterV2.json +0 -1
- package/ext/aastar-shared-config/src/abis/index.ts +0 -45
- package/ext/aastar-shared-config/src/abis/xPNTsFactory.json +0 -1
- package/ext/aastar-shared-config/src/abis/xPNTsToken.json +0 -1
- package/ext/aastar-shared-config/src/branding.ts +0 -32
- package/ext/aastar-shared-config/src/communities.ts +0 -93
- package/ext/aastar-shared-config/src/constants.ts +0 -67
- package/ext/aastar-shared-config/src/contract-addresses.ts +0 -95
- package/ext/aastar-shared-config/src/contract-versions.ts +0 -374
- package/ext/aastar-shared-config/src/contracts.ts +0 -414
- package/ext/aastar-shared-config/src/index.ts +0 -14
- package/ext/aastar-shared-config/src/networks.ts +0 -117
- package/ext/aastar-shared-config/sync-abis.sh +0 -92
- package/ext/aastar-shared-config/sync-versions.mjs +0 -150
- package/ext/aastar-shared-config/tsconfig.json +0 -18
- package/ext/aastar-shared-config/tsup.config.ts +0 -10
- package/ext/aastar-shared-config/verify-all.sh +0 -207
- package/ext/aastar-shared-config/verify-contracts.sh +0 -85
- package/ext/aastar-shared-config/verify-mysbt-v243.mjs +0 -27
- package/ext/aastar-shared-config/verify-onchain-versions.mjs +0 -93
- package/l4-setup.sh +0 -1
- package/lib/SHARED_CONFIG_REFERENCE.md +0 -133
- package/lib/shared-config/.env.example +0 -6
- package/lib/shared-config/.github/workflows/check-secrets.yml +0 -257
- package/lib/shared-config/AGENTS.md +0 -21
- package/lib/shared-config/CHANGELOG.md +0 -99
- package/lib/shared-config/LICENSE +0 -21
- package/lib/shared-config/QUICK_START.md +0 -215
- package/lib/shared-config/README.md +0 -412
- package/lib/shared-config/SHARED_CONFIG_SUMMARY.md +0 -273
- package/lib/shared-config/check-locker-status.mjs +0 -7
- package/lib/shared-config/favicon.ico +0 -0
- package/lib/shared-config/generate-comparison-table.sh +0 -67
- package/lib/shared-config/package.json +0 -46
- package/lib/shared-config/pnpm-lock.yaml +0 -1182
- package/lib/shared-config/src/abis/BLSAggregator.json +0 -1
- package/lib/shared-config/src/abis/DVTValidator.json +0 -1
- package/lib/shared-config/src/abis/GToken.json +0 -1
- package/lib/shared-config/src/abis/GTokenStaking.json +0 -1
- package/lib/shared-config/src/abis/MySBT.json +0 -1
- package/lib/shared-config/src/abis/PaymasterFactory.json +0 -1
- package/lib/shared-config/src/abis/PaymasterV4.json +0 -1098
- package/lib/shared-config/src/abis/Registry.json +0 -1
- package/lib/shared-config/src/abis/SimpleAccount.json +0 -557
- package/lib/shared-config/src/abis/SimpleAccountFactory.json +0 -87
- package/lib/shared-config/src/abis/SuperPaymasterV2.json +0 -1
- package/lib/shared-config/src/abis/index.ts +0 -45
- package/lib/shared-config/src/abis/xPNTsFactory.json +0 -1
- package/lib/shared-config/src/abis/xPNTsToken.json +0 -1
- package/lib/shared-config/src/branding.ts +0 -32
- package/lib/shared-config/src/communities.ts +0 -93
- package/lib/shared-config/src/constants.ts +0 -67
- package/lib/shared-config/src/contract-addresses.ts +0 -95
- package/lib/shared-config/src/contract-versions.ts +0 -374
- package/lib/shared-config/src/contracts.ts +0 -414
- package/lib/shared-config/src/index.ts +0 -14
- package/lib/shared-config/src/networks.ts +0 -117
- package/lib/shared-config/sync-abis.sh +0 -92
- package/lib/shared-config/sync-versions.mjs +0 -150
- package/lib/shared-config/tsconfig.json +0 -18
- package/lib/shared-config/tsup.config.ts +0 -10
- package/lib/shared-config/verify-all.sh +0 -207
- package/lib/shared-config/verify-contracts.sh +0 -85
- package/lib/shared-config/verify-mysbt-v243.mjs +0 -27
- package/lib/shared-config/verify-onchain-versions.mjs +0 -93
- package/packages/account/__tests__/index.test.ts +0 -9
- package/packages/account/node_modules/.bin/tsc +0 -21
- package/packages/account/node_modules/.bin/tsserver +0 -21
- package/packages/account/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/account/package.json +0 -21
- package/packages/account/src/accounts/simple.ts +0 -84
- package/packages/account/src/eoa.ts +0 -31
- package/packages/account/src/index.ts +0 -61
- package/packages/account/tsconfig.json +0 -12
- package/packages/analytics/README.md +0 -68
- package/packages/analytics/__tests__/index.test.ts +0 -25
- package/packages/analytics/data/attribution_dataset.csv +0 -29
- package/packages/analytics/data/complete_dataset.csv +0 -29
- package/packages/analytics/data/eth_price_cache.json +0 -4
- package/packages/analytics/data/full_dataset.csv +0 -11
- package/packages/analytics/data/full_dataset.json +0 -134
- package/packages/analytics/data/parsed_transactions.csv +0 -29
- package/packages/analytics/node_modules/.bin/tsc +0 -21
- package/packages/analytics/node_modules/.bin/tsserver +0 -21
- package/packages/analytics/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/analytics/package.json +0 -25
- package/packages/analytics/reports/full/attribution_analysis_20260119.md +0 -42
- package/packages/analytics/reports/full/attribution_analysis_fresh_20260119.md +0 -67
- package/packages/analytics/reports/full/competitive_analysis_20260119.md +0 -103
- package/packages/analytics/reports/full/comprehensive_analysis_20260119.md +0 -107
- package/packages/analytics/reports/full/comprehensive_analysis_v4_1_20260119.md +0 -74
- package/packages/analytics/reports/full/economic_audit_v4_2_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_3_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_4_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_5_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_6_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_final_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_final_v2_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_final_v3_20260119.md +0 -74
- package/packages/analytics/reports/full/profit_audit_v4_final_v4_20260119.md +0 -75
- package/packages/analytics/reports/full/profit_audit_v4_final_v5_20260119.md +0 -76
- package/packages/analytics/reports/full/two_layer_analysis_20260119.md +0 -81
- package/packages/analytics/reports/full/two_layer_analysis_academic_20260119.md +0 -81
- package/packages/analytics/reports/full/two_layer_analysis_dynamic_20260119.md +0 -81
- package/packages/analytics/reports/full/two_layer_analysis_final_20260119.md +0 -81
- package/packages/analytics/reports/full/two_layer_analysis_final_fixed_20260119.md +0 -81
- package/packages/analytics/reports/full/two_layer_analysis_fixed_20260119.md +0 -52
- package/packages/analytics/reports/full/two_layer_analysis_normalized_20260119.md +0 -81
- package/packages/analytics/reports/full/tx_0xc30cfcbb.md +0 -39
- package/packages/analytics/src/analyzers/AttributionAnalyzer.ts +0 -124
- package/packages/analytics/src/analyzers/ComparisonAnalyzer.ts +0 -89
- package/packages/analytics/src/analyzers/TransactionAnalyzer.ts +0 -111
- package/packages/analytics/src/analyzers/TrendAnalyzer.ts +0 -107
- package/packages/analytics/src/cli-analyze-tx.ts +0 -45
- package/packages/analytics/src/cli.ts +0 -39
- package/packages/analytics/src/core/BenchmarkLoader.ts +0 -163
- package/packages/analytics/src/core/CostCalculator.ts +0 -202
- package/packages/analytics/src/core/DataCollector.ts +0 -245
- package/packages/analytics/src/gas-analyzer-v4.ts +0 -118
- package/packages/analytics/src/gas-analyzer.ts +0 -184
- package/packages/analytics/src/index.ts +0 -145
- package/packages/analytics/src/test-logparser.ts +0 -63
- package/packages/analytics/src/utils/EventDecoder.ts +0 -152
- package/packages/analytics/src/utils/LogParser.ts +0 -220
- package/packages/analytics/src/utils/PriceOracle.ts +0 -117
- package/packages/analytics/test/AttributionAnalyzer.test.ts +0 -42
- package/packages/analytics/test/CostCalculator.test.ts +0 -75
- package/packages/analytics/tsconfig.json +0 -12
- package/packages/community/__tests__/index.test.ts +0 -9
- package/packages/community/node_modules/.bin/tsc +0 -21
- package/packages/community/node_modules/.bin/tsserver +0 -21
- package/packages/community/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/community/package.json +0 -27
- package/packages/community/src/index.ts +0 -326
- package/packages/community/tsconfig.json +0 -8
- package/packages/core/__tests__/actions/account-comprehensive.test.ts +0 -92
- package/packages/core/__tests__/actions/aggregator.test.ts +0 -62
- package/packages/core/__tests__/actions/comprehensive-batch1.test.ts +0 -86
- package/packages/core/__tests__/actions/comprehensive-batch2.test.ts +0 -39
- package/packages/core/__tests__/actions/comprehensive-batch3.test.ts +0 -35
- package/packages/core/__tests__/actions/comprehensive-error.test.ts +0 -115
- package/packages/core/__tests__/actions/dvt.test.ts +0 -39
- package/packages/core/__tests__/actions/edge-cases.test.ts +0 -39
- package/packages/core/__tests__/actions/error-paths.test.ts +0 -82
- package/packages/core/__tests__/actions/factory.test.ts +0 -81
- package/packages/core/__tests__/actions/faucet.test.ts +0 -131
- package/packages/core/__tests__/actions/paymaster.test.ts +0 -116
- package/packages/core/__tests__/actions/registry.test.ts +0 -81
- package/packages/core/__tests__/actions/reputation.test.ts +0 -43
- package/packages/core/__tests__/actions/sbt.test.ts +0 -145
- package/packages/core/__tests__/actions/staking.test.ts +0 -30
- package/packages/core/__tests__/actions/superPaymaster.test.ts +0 -158
- package/packages/core/__tests__/actions/tokens-extended.test.ts +0 -18
- package/packages/core/__tests__/actions/tokens.test.ts +0 -122
- package/packages/core/__tests__/clients.test.ts +0 -77
- package/packages/core/__tests__/contracts-config.test.ts +0 -69
- package/packages/core/__tests__/index.test.ts +0 -9
- package/packages/core/__tests__/mocks/client.ts +0 -40
- package/packages/core/node_modules/.bin/tsc +0 -21
- package/packages/core/node_modules/.bin/tsserver +0 -21
- package/packages/core/node_modules/.bin/tsx +0 -21
- package/packages/core/node_modules/.bin/vite +0 -21
- package/packages/core/node_modules/.bin/vitest +0 -21
- package/packages/core/node_modules/.bin/yaml +0 -21
- package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/core/package.json +0 -25
- package/packages/core/src/abis/BLSAggregator.json +0 -686
- package/packages/core/src/abis/BLSValidator.json +0 -42
- package/packages/core/src/abis/DVTValidator.json +0 -368
- package/packages/core/src/abis/Eip7702Support.json +0 -24
- package/packages/core/src/abis/EntryPoint.json +0 -1382
- package/packages/core/src/abis/GToken.json +0 -513
- package/packages/core/src/abis/GTokenStaking.json +0 -949
- package/packages/core/src/abis/LegacyAccount.json +0 -625
- package/packages/core/src/abis/MySBT.json +0 -1518
- package/packages/core/src/abis/Paymaster.json +0 -1143
- package/packages/core/src/abis/PaymasterFactory.json +0 -640
- package/packages/core/src/abis/Registry.json +0 -1942
- package/packages/core/src/abis/ReputationSystem.json +0 -699
- package/packages/core/src/abis/SenderCreator.json +0 -99
- package/packages/core/src/abis/Simple7702Account.json +0 -395
- package/packages/core/src/abis/SimpleAccount.json +0 -560
- package/packages/core/src/abis/SimpleAccountFactory.json +0 -111
- package/packages/core/src/abis/SimpleAccountFactoryV08.json +0 -87
- package/packages/core/src/abis/SimpleAccountV08.json +0 -557
- package/packages/core/src/abis/SuperPaymaster.json +0 -1781
- package/packages/core/src/abis/UserOperationLib.json +0 -57
- package/packages/core/src/abis/aPNTs.json +0 -1160
- package/packages/core/src/abis/abi.config.json +0 -24
- package/packages/core/src/abis/index.ts +0 -91
- package/packages/core/src/abis/xPNTsFactory.json +0 -718
- package/packages/core/src/abis/xPNTsToken.json +0 -1280
- package/packages/core/src/actions/StateValidator.ts +0 -253
- package/packages/core/src/actions/account.ts +0 -190
- package/packages/core/src/actions/aggregator.ts +0 -371
- package/packages/core/src/actions/dvt.ts +0 -269
- package/packages/core/src/actions/entryPoint.ts +0 -89
- package/packages/core/src/actions/factory.ts +0 -732
- package/packages/core/src/actions/faucet.ts +0 -280
- package/packages/core/src/actions/index.ts +0 -15
- package/packages/core/src/actions/paymaster.ts +0 -780
- package/packages/core/src/actions/registry.ts +0 -961
- package/packages/core/src/actions/reputation.ts +0 -668
- package/packages/core/src/actions/sbt.ts +0 -916
- package/packages/core/src/actions/staking.ts +0 -576
- package/packages/core/src/actions/superPaymaster.ts +0 -1093
- package/packages/core/src/actions/tokens.ts +0 -481
- package/packages/core/src/branding.ts +0 -32
- package/packages/core/src/clients/BaseClient.ts +0 -78
- package/packages/core/src/clients/BundlerClient.ts +0 -132
- package/packages/core/src/clients/types.ts +0 -69
- package/packages/core/src/clients.ts +0 -13
- package/packages/core/src/communities.ts +0 -93
- package/packages/core/src/config/ContractConfigManager.ts +0 -63
- package/packages/core/src/constants.ts +0 -114
- package/packages/core/src/contract-addresses.ts +0 -118
- package/packages/core/src/contract-versions.ts +0 -374
- package/packages/core/src/contracts.ts +0 -414
- package/packages/core/src/crypto/blsSigner.ts +0 -124
- package/packages/core/src/crypto/index.ts +0 -1
- package/packages/core/src/errors/index.ts +0 -173
- package/packages/core/src/index.ts +0 -23
- package/packages/core/src/networks.ts +0 -127
- package/packages/core/src/requirementChecker.ts +0 -225
- package/packages/core/src/roles.ts +0 -244
- package/packages/core/src/utils.ts +0 -23
- package/packages/core/src/validators/index.ts +0 -88
- package/packages/core/tsconfig.json +0 -13
- package/packages/dapp/__tests__/index.test.ts +0 -9
- package/packages/dapp/node_modules/.bin/tsc +0 -21
- package/packages/dapp/node_modules/.bin/tsserver +0 -21
- package/packages/dapp/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/dapp/package.json +0 -28
- package/packages/dapp/src/index.ts +0 -4
- package/packages/dapp/src/ui/components/EvaluationPanel.tsx +0 -40
- package/packages/dapp/src/ui/hooks/useCreditScore.ts +0 -44
- package/packages/dapp/src/ui/hooks/useSuperPaymaster.ts +0 -31
- package/packages/dapp/src/ui/index.ts +0 -22
- package/packages/dapp/tsconfig.json +0 -13
- package/packages/enduser/__tests__/CommunityClient.test.ts +0 -205
- package/packages/enduser/__tests__/UserClient.test.ts +0 -294
- package/packages/enduser/__tests__/index.test.ts +0 -16
- package/packages/enduser/__tests__/mocks/client.ts +0 -22
- package/packages/enduser/node_modules/.bin/tsc +0 -21
- package/packages/enduser/node_modules/.bin/tsserver +0 -21
- package/packages/enduser/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/enduser/package.json +0 -26
- package/packages/enduser/src/CommunityClient.ts +0 -235
- package/packages/enduser/src/UserClient.ts +0 -447
- package/packages/enduser/src/index.ts +0 -2
- package/packages/enduser/src/testAccountManager.ts +0 -374
- package/packages/enduser/tsconfig.json +0 -10
- package/packages/identity/__tests__/index.test.ts +0 -9
- package/packages/identity/node_modules/.bin/tsc +0 -21
- package/packages/identity/node_modules/.bin/tsserver +0 -21
- package/packages/identity/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/identity/package.json +0 -23
- package/packages/identity/src/index.ts +0 -114
- package/packages/identity/src/mysbt.ts +0 -48
- package/packages/identity/tsconfig.json +0 -12
- package/packages/operator/__tests__/PaymasterOperatorClient.test.ts +0 -258
- package/packages/operator/__tests__/ProtocolClient.test.ts +0 -135
- package/packages/operator/__tests__/index.test.ts +0 -16
- package/packages/operator/__tests__/mocks/client.ts +0 -22
- package/packages/operator/node_modules/.bin/tsc +0 -21
- package/packages/operator/node_modules/.bin/tsserver +0 -21
- package/packages/operator/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/operator/package.json +0 -26
- package/packages/operator/src/PaymasterOperatorClient.ts +0 -454
- package/packages/operator/src/ProtocolClient.ts +0 -154
- package/packages/operator/src/index.ts +0 -2
- package/packages/operator/tsconfig.json +0 -10
- package/packages/patterns/node_modules/.bin/tsc +0 -21
- package/packages/patterns/node_modules/.bin/tsserver +0 -21
- package/packages/paymaster/__tests__/PaymasterOperator.test.ts +0 -123
- package/packages/paymaster/__tests__/index.test.ts +0 -9
- package/packages/paymaster/node_modules/.bin/tsc +0 -21
- package/packages/paymaster/node_modules/.bin/tsserver +0 -21
- package/packages/paymaster/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/paymaster/package.json +0 -23
- package/packages/paymaster/src/SuperPaymaster/index.ts +0 -168
- package/packages/paymaster/src/V4/BundlerCompat.ts +0 -47
- package/packages/paymaster/src/V4/PaymasterClient.ts +0 -490
- package/packages/paymaster/src/V4/PaymasterOperator.ts +0 -282
- package/packages/paymaster/src/V4/PaymasterUtils.ts +0 -199
- package/packages/paymaster/src/V4/SuperPaymasterClient.ts +0 -129
- package/packages/paymaster/src/V4/index.ts +0 -4
- package/packages/paymaster/src/index.ts +0 -5
- package/packages/paymaster/tsconfig.json +0 -16
- package/packages/sdk/README.md +0 -171
- package/packages/sdk/__tests__/index.test.ts +0 -9
- package/packages/sdk/aastar/package.json +0 -21
- package/packages/sdk/aastar/src/index.ts +0 -3
- package/packages/sdk/aastar/tsconfig.json +0 -8
- package/packages/sdk/examples/config.json +0 -1
- package/packages/sdk/examples/regression_test.ts +0 -106
- package/packages/sdk/node_modules/.bin/tsc +0 -21
- package/packages/sdk/node_modules/.bin/tsserver +0 -21
- package/packages/sdk/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/sdk/package.json +0 -34
- package/packages/sdk/src/clients/admin.ts +0 -56
- package/packages/sdk/src/clients/endUser.ts +0 -428
- package/packages/sdk/src/utils/testScenarios.ts +0 -128
- package/packages/sdk/tests/scenarios/01_onboard_community.ts +0 -62
- package/packages/sdk/tests/scenarios/02_onboard_operator.ts +0 -109
- package/packages/sdk/tests/scenarios/03_onboard_user.ts +0 -53
- package/packages/sdk/tests/scenarios/04_gasless_tx_flow.ts +0 -68
- package/packages/sdk/tests/scenarios/check_entrypoint.ts +0 -19
- package/packages/sdk/tests/scenarios/check_initialization.ts +0 -65
- package/packages/sdk/tests/scenarios/debug_addresses.ts +0 -26
- package/packages/sdk/tests/scenarios/diagnose_scenario4.ts +0 -55
- package/packages/sdk/tests/scenarios/setup.ts +0 -33
- package/packages/sdk/tests/scenarios/test_entrypoint_nonce.ts +0 -46
- package/packages/sdk/tsconfig.json +0 -12
- package/packages/tokens/__tests__/index.test.ts +0 -9
- package/packages/tokens/node_modules/.bin/tsc +0 -21
- package/packages/tokens/node_modules/.bin/tsserver +0 -21
- package/packages/tokens/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/tokens/package.json +0 -23
- package/packages/tokens/src/index.ts +0 -258
- package/packages/tokens/tsconfig.json +0 -12
- package/pnpm-workspace.yaml +0 -2
- package/publish.sh +0 -30
- package/run_l4_gasless_regression.sh +0 -109
- package/run_sdk_regression.sh +0 -232
- package/scripts/00_utils.ts +0 -59
- package/scripts/00_verify_phase1.ts +0 -130
- package/scripts/01_1_prep_gtoken.ts +0 -81
- package/scripts/01_2_register_sbt.ts +0 -88
- package/scripts/01_3_prep_tokens_paymaster.ts +0 -102
- package/scripts/01_prepare_all.ts +0 -271
- package/scripts/02_test_eoa.ts +0 -50
- package/scripts/03_test_standard_aa.ts +0 -173
- package/scripts/04_0_check_deploy.ts +0 -24
- package/scripts/04_1_check_allowance.ts +0 -44
- package/scripts/04_2_construct_verify.ts +0 -96
- package/scripts/04_3_verify_estimate.ts +0 -66
- package/scripts/04_4_verify_pack.ts +0 -74
- package/scripts/04_test_paymaster_v4.ts +0 -217
- package/scripts/05_1_deposit.ts +0 -48
- package/scripts/05_test_superpaymaster.ts +0 -380
- package/scripts/06_local_test_v3_admin.ts +0 -163
- package/scripts/06_local_test_v3_execution.ts +0 -132
- package/scripts/06_local_test_v3_full.ts +0 -490
- package/scripts/06_local_test_v3_funding.ts +0 -124
- package/scripts/06_local_test_v3_reputation.ts +0 -234
- package/scripts/07_local_test_v3_audit.ts +0 -181
- package/scripts/08_local_test_registry_lifecycle.ts +0 -382
- package/scripts/09_local_test_community_lifecycle.ts +0 -385
- package/scripts/09_local_test_community_simple.ts +0 -108
- package/scripts/09_scenario_bread_independent.ts +0 -247
- package/scripts/10_scenario_super_shared.ts +0 -196
- package/scripts/10_test_protocol_admin_full.ts +0 -173
- package/scripts/11_scenario_hacker_defense.ts +0 -104
- package/scripts/11_test_core_flows_full.ts +0 -279
- package/scripts/12_test_slash_mechanism.ts +0 -205
- package/scripts/12_test_slash_queries.ts +0 -83
- package/scripts/12_test_staking_exit.ts +0 -152
- package/scripts/12_test_staking_slash.ts +0 -301
- package/scripts/12_test_tier2_slash.ts +0 -139
- package/scripts/13_test_sbt_burn_linkage.ts +0 -266
- package/scripts/14_test_credit_redesign.ts +0 -266
- package/scripts/15_test_bls_full.ts +0 -148
- package/scripts/15_test_dvt_bls_full.ts +0 -140
- package/scripts/17_test_cross_role_collaboration.ts +0 -95
- package/scripts/18_sdk_e2e_verification.ts +0 -67
- package/scripts/18_test_dvt_sdk_flow.ts +0 -138
- package/scripts/18_test_lifecycle_completion.ts +0 -144
- package/scripts/19_sdk_experiment_runner.ts +0 -207
- package/scripts/19_sdk_experiment_runner.ts.backup +0 -391
- package/scripts/20_sdk_full_capability.ts +0 -95
- package/scripts/20_test_superpaymaster_new_apis.ts +0 -193
- package/scripts/21_test_paymasterv4_complete.ts +0 -341
- package/scripts/22_test_bls_signing.ts +0 -260
- package/scripts/23_test_middleware.ts +0 -197
- package/scripts/98_edge_reentrancy.ts +0 -85
- package/scripts/99_bug_hunting_fast.ts +0 -99
- package/scripts/analyze_abi_coverage.ts +0 -169
- package/scripts/analyze_missing_functions.ts +0 -136
- package/scripts/canary-bundler.ts +0 -47
- package/scripts/check-admin.ts +0 -95
- package/scripts/check-chainlink.ts +0 -28
- package/scripts/check-jason-status.ts +0 -85
- package/scripts/check-roles.ts +0 -36
- package/scripts/clear-nonce.ts +0 -47
- package/scripts/collect_industry_baseline.ts +0 -236
- package/scripts/complete-jack-superpaymaster.ts +0 -171
- package/scripts/complete_env_config.ts +0 -97
- package/scripts/deploy-sync.ts +0 -104
- package/scripts/deploy_and_init_v3.sh +0 -134
- package/scripts/deploy_anvil_accounts.ts +0 -144
- package/scripts/deploy_jason_pm.ts +0 -114
- package/scripts/deploy_paymaster_v4.ts +0 -139
- package/scripts/deploy_test_accounts.ts +0 -401
- package/scripts/deprecated/check_aa_entrypoint.ts +0 -29
- package/scripts/deprecated/check_paymaster_deposits.ts +0 -45
- package/scripts/deprecated/debug_aoa_function.ts +0 -28
- package/scripts/deprecated/debug_aoa_issue.ts +0 -16
- package/scripts/deprecated/debug_pimlico_aa23.ts +0 -40
- package/scripts/deprecated/debug_summary.ts +0 -34
- package/scripts/deprecated/deploy_v07_aa.ts +0 -99
- package/scripts/deprecated/fix_all_issues.ts +0 -61
- package/scripts/deprecated/fund_bpnts.ts +0 -52
- package/scripts/deprecated/get_factory_addresses.ts +0 -28
- package/scripts/deprecated/recheck_pim.ts +0 -34
- package/scripts/dev_tools/extract_abis.sh +0 -151
- package/scripts/dev_tools/extract_addresses_to_env.sh +0 -67
- package/scripts/dev_tools/final_safe_harmonize.py +0 -77
- package/scripts/dev_tools/safe_harmonize.py +0 -107
- package/scripts/dev_tools/surgical_harmonize.py +0 -83
- package/scripts/experiment/stage3/SETUP_GUIDE.md +0 -258
- package/scripts/experiment/stage3/archived_scripts/00_token_distribution.ts +0 -78
- package/scripts/experiment/stage3/archived_scripts/01_dao_launch.ts +0 -96
- package/scripts/experiment/stage3/archived_scripts/01b_bread_launch.ts +0 -112
- package/scripts/experiment/stage3/archived_scripts/02_operator_setup.ts +0 -84
- package/scripts/experiment/stage3/archived_scripts/02b_operator_b_setup.ts +0 -104
- package/scripts/experiment/stage3/archived_scripts/02c_finalize_operators.ts +0 -86
- package/scripts/experiment/stage3/archived_scripts/02d_operator_collateral.ts +0 -89
- package/scripts/experiment/stage3/archived_scripts/03_user_onboarding.ts +0 -83
- package/scripts/experiment/stage3/archived_scripts/03b_deploy_aa_account.ts +0 -61
- package/scripts/experiment/stage3/archived_scripts/03c_aa_onboarding.ts +0 -104
- package/scripts/experiment/stage3/archived_scripts/03d_mint_points.ts +0 -60
- package/scripts/experiment/stage3/archived_scripts/04_benchmarking.ts +0 -100
- package/scripts/experiment/stage3/archived_scripts/05_multi_op_setup.ts +0 -149
- package/scripts/experiment/stage3/archived_scripts/README.md +0 -58
- package/scripts/experiment/stage3/archived_scripts/check_roles.ts +0 -29
- package/scripts/experiment/stage3/archived_scripts/decode_error.ts +0 -23
- package/scripts/experiment/stage3/archived_scripts/fund_user.ts +0 -51
- package/scripts/experiment/stage3/archived_scripts/gen_b_key.ts +0 -3
- package/scripts/experiment/stage3/archived_scripts/gen_keys.ts +0 -4
- package/scripts/experiment/stage3/archived_scripts/setup.ts +0 -105
- package/scripts/experiment/stage3/archived_scripts/test_key.ts +0 -4
- package/scripts/experiment/stage3/archived_scripts/verify_state.ts +0 -59
- package/scripts/experiment/stage3/refactored/00_token_distribution.ts +0 -46
- package/scripts/experiment/stage3/refactored/02_operator_setup.ts +0 -65
- package/scripts/experiment/stage3/refactored/03_user_onboarding.ts +0 -68
- package/scripts/experiment/stage3/refactored/05_multi_op_setup.ts +0 -63
- package/scripts/experiment/stage3/refactored/README.md +0 -71
- package/scripts/extract-docs.sh +0 -72
- package/scripts/fund-jack.ts +0 -38
- package/scripts/generate_env_from_deployment.ts +0 -109
- package/scripts/inspect-anni-token.ts +0 -116
- package/scripts/inspect-factory.ts +0 -83
- package/scripts/l4-debug-bob.ts +0 -62
- package/scripts/l4-paymasterv4-transfer-test.ts +0 -220
- package/scripts/l4-setup.ts +0 -1347
- package/scripts/l4-state.json +0 -82
- package/scripts/manual-update-price.ts +0 -39
- package/scripts/phase1_verify_contracts.ts +0 -207
- package/scripts/pre_test_sync.ts +0 -83
- package/scripts/prepare_sepolia_resources.ts +0 -154
- package/scripts/publish_all.sh +0 -39
- package/scripts/query-jack-token.ts +0 -22
- package/scripts/quick_setup.ts +0 -124
- package/scripts/quick_setup_account.ts +0 -80
- package/scripts/run_automated_experiment.sh +0 -121
- package/scripts/run_daily_experiment.ts +0 -70
- package/scripts/run_full_regression.sh +0 -38
- package/scripts/run_l4_gasless_regression.sh +0 -32
- package/scripts/run_sdk_experiment.sh +0 -13
- package/scripts/run_sdk_regression-v2.sh +0 -38
- package/scripts/sdk_regression_v2.ts +0 -148
- package/scripts/security_audit.sh +0 -172
- package/scripts/setup-bbq-community.ts +0 -187
- package/scripts/setup-dancing-community.ts +0 -223
- package/scripts/setup_test_accounts.ts +0 -88
- package/scripts/setup_test_environment.ts +0 -147
- package/scripts/sync_anvil_config.cjs +0 -44
- package/scripts/sync_config_to_env.ts +0 -88
- package/scripts/sync_contract_addresses.ts +0 -186
- package/scripts/sync_sepolia_config.cjs +0 -90
- package/scripts/sync_sepolia_config.mjs +0 -74
- package/scripts/test-brown-v4-deploy.ts +0 -90
- package/scripts/test-faucet-and-gasless.ts +0 -150
- package/scripts/test-jack-gasless.ts +0 -119
- package/scripts/test-jack-registration.ts +0 -133
- package/scripts/test-jack-superpaymaster-api.ts +0 -112
- package/scripts/test-kms-gasless.ts +0 -352
- package/scripts/update-price-dvt.ts +0 -53
- package/scripts/update_env_from_config.ts +0 -83
- package/scripts/v2_regression/00_validate_env.ts +0 -101
- package/scripts/v2_regression/01_setup_and_fund.ts +0 -132
- package/scripts/v2_regression/02_operator_onboarding.ts +0 -300
- package/scripts/v2_regression/03_community_registry.ts +0 -173
- package/scripts/v2_regression/04_enduser_flow.ts +0 -174
- package/scripts/v2_regression/05_admin_audit.ts +0 -157
- package/scripts/v2_regression/README.md +0 -161
- package/scripts/validate_env.ts +0 -112
- package/scripts/verify-bob-token.ts +0 -41
- package/scripts/verify-tx-status.ts +0 -81
- package/scripts/verify_onchain_milestone.ts +0 -114
- package/scripts/verify_phase1.ts +0 -66
- package/scripts/verify_phase2.ts +0 -66
- package/sdk-abi-coverage.sh +0 -1
- package/sdk-build-and-test.sh +0 -1
- package/sdk-test-coverage.sh +0 -1
- package/sdk_experiment_data.csv +0 -4
- package/simple-test-paymaster.sh +0 -2
- package/simple-test-superpaymaster.sh +0 -3
- package/tests/check-aa-balance.ts +0 -31
- package/tests/l1-regression.test.ts +0 -437
- package/tests/l4-test-anni-gasless.ts +0 -517
- package/tests/l4-test-jason1-gasless.ts +0 -158
- package/tests/l4-test-jason2-gasless.ts +0 -180
- package/tests/l4-test-pmv4-deposit.ts +0 -111
- package/tests/l4-test-pmv4-gasless.ts +0 -166
- package/tests/l4-test-pmv4-submit.ts +0 -223
- package/tests/regression/README.md +0 -168
- package/tests/regression/config.ts +0 -217
- package/tests/regression/display-versions.ts +0 -85
- package/tests/regression/index.ts +0 -67
- package/tests/regression/l1-tests.ts +0 -248
- package/tests/regression/l2-tests.ts +0 -227
- package/tests/regression/l3-tests.ts +0 -28
- package/tests/regression/l4-comprehensive-gasless.ts +0 -478
- package/tests/regression/l4-gasless.ts +0 -999
- package/tests/regression/l4-reputation-tiers.ts +0 -102
- package/tests/regression/l4-runner.ts +0 -52
- package/tests/reports/phase1_contract_verification.md +0 -45
- package/tests/test-bundler-compat.ts +0 -132
- package/tests/test-candide-bundler.ts +0 -117
- package/tests/test-candide-paymaster.ts +0 -101
- package/tests/test-candide-sdk.ts +0 -116
- package/tests/test-candide-simple.ts +0 -204
- package/tests/test-pimlico-complete.ts +0 -134
- package/tests/utils/contractVerifier.ts +0 -237
- package/tests/utils/userOpHelper.ts +0 -194
- package/tsconfig.build.json +0 -23
- package/tsconfig.json +0 -27
- package/typedoc.json +0 -25
- package/update-version.sh +0 -20
- package/vitest.config.ts +0 -17
|
@@ -1,2714 +0,0 @@
|
|
|
1
|
-
> **gTokenActions**(): (`client`) => [`TokenActions`](../type-aliases/TokenActions.md)
|
|
2
|
-
|
|
3
|
-
Defined in: [packages/core/src/actions/tokens.ts:81](https://github.com/AAStarCommunity/aastar-sdk/blob/f3911a6f6e88b2f77186db63ad0182c2cfe13b9d/packages/core/src/actions/tokens.ts#L81)
|
|
4
|
-
|
|
5
|
-
## Returns
|
|
6
|
-
|
|
7
|
-
> (`client`): [`TokenActions`](../type-aliases/TokenActions.md)
|
|
8
|
-
|
|
9
|
-
### Parameters
|
|
10
|
-
|
|
11
|
-
#### client
|
|
12
|
-
|
|
13
|
-
\{ `account`: `undefined`; `batch?`: \{ `multicall?`: `boolean` \| \{ `batchSize?`: `number`; `deployless?`: `boolean`; `wait?`: `number`; \}; \}; `cacheTime`: `number`; `call`: (`parameters`) => `Promise`\<[`CallReturnType`](https://viem.sh/docs/index.html)\>; `ccipRead?`: `false` \| \{ `request?`: (`parameters`) => `Promise`\<`` `0x${string}` ``\>; \}; `chain`: [`Chain`](https://viem.sh/docs/index.html) \| `undefined`; `createAccessList`: (`parameters`) => `Promise`\<\{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `gasUsed`: `bigint`; \}\>; `createBlockFilter`: () => `Promise`\<\{ `id`: `` `0x${string}` ``; `request`: [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<readonly \[\{ `Method`: `"eth_getFilterChanges"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: ...[] \| ...[]; \}, \{ `Method`: `"eth_getFilterLogs"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: [`RpcLog`](https://viem.sh/docs/index.html)[]; \}, \{ `Method`: `"eth_uninstallFilter"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: `boolean`; \}\]\>; `type`: `"block"`; \}\>; `createContractEventFilter`: \<`abi`, `eventName`, `args`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`CreateContractEventFilterReturnType`](https://viem.sh/docs/index.html)\<`abi`, `eventName`, `args`, `strict`, `fromBlock`, `toBlock`\>\>; `createEventFilter`: \<`abiEvent`, `abiEvents`, `strict`, `fromBlock`, `toBlock`, `_EventName`, `_Args`\>(`args?`) => `Promise`\<\{ \[K in string \| number \| symbol\]: Filter\<"event", abiEvents, \_EventName, \_Args, strict, fromBlock, toBlock\>\[K\] \}\>; `createPendingTransactionFilter`: () => `Promise`\<\{ `id`: `` `0x${string}` ``; `request`: [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<readonly \[\{ `Method`: `"eth_getFilterChanges"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: ...[] \| ...[]; \}, \{ `Method`: `"eth_getFilterLogs"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: [`RpcLog`](https://viem.sh/docs/index.html)[]; \}, \{ `Method`: `"eth_uninstallFilter"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: `boolean`; \}\]\>; `type`: `"transaction"`; \}\>; `estimateContractGas`: \<`chain`, `abi`, `functionName`, `args`\>(`args`) => `Promise`\<`bigint`\>; `estimateFeesPerGas`: \<`chainOverride`, `type`\>(`args?`) => `Promise`\<[`EstimateFeesPerGasReturnType`](https://viem.sh/docs/index.html)\<`type`\>\>; `estimateGas`: (`args`) => `Promise`\<`bigint`\>; `estimateMaxPriorityFeePerGas`: \<`chainOverride`\>(`args?`) => `Promise`\<`bigint`\>; `experimental_blockTag?`: [`BlockTag`](https://viem.sh/docs/index.html); `extend`: \<`client`\>(`fn`) => [`Client`](https://viem.sh/docs/index.html)\<[`Transport`](https://viem.sh/docs/index.html), [`Chain`](https://viem.sh/docs/index.html) \| `undefined`, `undefined`, [`PublicRpcSchema`](https://viem.sh/docs/index.html), \{ \[K in string \| number \| symbol\]: client\[K\] \} & [`PublicActions`](https://viem.sh/docs/index.html)\<[`Transport`](https://viem.sh/docs/index.html), [`Chain`](https://viem.sh/docs/index.html) \| `undefined`\>\>; `fillTransaction`: \<`chainOverride`, `accountOverride`\>(`args`) => `Promise`\<[`FillTransactionReturnType`](https://viem.sh/docs/index.html)\<[`Chain`](https://viem.sh/docs/index.html) \| `undefined`, `chainOverride`\>\>; `getBalance`: (`args`) => `Promise`\<`bigint`\>; `getBlobBaseFee`: () => `Promise`\<`bigint`\>; `getBlock`: \<`includeTransactions`, `blockTag`\>(`args?`) => `Promise`\<\{ `baseFeePerGas`: `bigint` \| `null`; `blobGasUsed`: `bigint`; `difficulty`: `bigint`; `excessBlobGas`: `bigint`; `extraData`: `` `0x${string}` ``; `gasLimit`: `bigint`; `gasUsed`: `bigint`; `hash`: `blockTag` *extends* `"pending"` ? `null` : `` `0x${string}` ``; `logsBloom`: `blockTag` *extends* `"pending"` ? `null` : `` `0x${string}` ``; `miner`: `` `0x${string}` ``; `mixHash`: `` `0x${string}` ``; `nonce`: `blockTag` *extends* `"pending"` ? `null` : `` `0x${string}` ``; `number`: `blockTag` *extends* `"pending"` ? `null` : `bigint`; `parentBeaconBlockRoot?`: `` `0x${string}` ``; `parentHash`: `` `0x${string}` ``; `receiptsRoot`: `` `0x${string}` ``; `sealFields`: `` `0x${string}` ``[]; `sha3Uncles`: `` `0x${string}` ``; `size`: `bigint`; `stateRoot`: `` `0x${string}` ``; `timestamp`: `bigint`; `totalDifficulty`: `bigint` \| `null`; `transactions`: `includeTransactions` *extends* `true` ? (\{ `accessList?`: `undefined`; `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId?`: ... \| ...; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"legacy"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity?`: `undefined`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip2930"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip1559"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes`: readonly ...[]; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas`: `bigint`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip4844"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList`: [`SignedAuthorizationList`](https://viem.sh/docs/index.html); `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip7702"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \})[] : `` `0x${string}` ``[]; `transactionsRoot`: `` `0x${string}` ``; `uncles`: `` `0x${string}` ``[]; `withdrawals?`: [`Withdrawal`](https://viem.sh/docs/index.html)[]; `withdrawalsRoot?`: `` `0x${string}` ``; \}\>; `getBlockNumber`: (`args?`) => `Promise`\<`bigint`\>; `getBlockTransactionCount`: (`args?`) => `Promise`\<`number`\>; `getBytecode`: (`args`) => `Promise`\<[`GetCodeReturnType`](https://viem.sh/docs/index.html)\>; `getChainId`: () => `Promise`\<`number`\>; `getCode`: (`args`) => `Promise`\<[`GetCodeReturnType`](https://viem.sh/docs/index.html)\>; `getContractEvents`: \<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`GetContractEventsReturnType`](https://viem.sh/docs/index.html)\<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>\>; `getEip712Domain`: (`args`) => `Promise`\<[`GetEip712DomainReturnType`](https://viem.sh/docs/index.html)\>; `getEnsAddress`: (`args`) => `Promise`\<[`GetEnsAddressReturnType`](https://viem.sh/docs/index.html)\>; `getEnsAvatar`: (`args`) => `Promise`\<[`GetEnsAvatarReturnType`](https://viem.sh/docs/index.html)\>; `getEnsName`: (`args`) => `Promise`\<[`GetEnsNameReturnType`](https://viem.sh/docs/index.html)\>; `getEnsResolver`: (`args`) => `Promise`\<`` `0x${string}` ``\>; `getEnsText`: (`args`) => `Promise`\<[`GetEnsTextReturnType`](https://viem.sh/docs/index.html)\>; `getFeeHistory`: (`args`) => `Promise`\<[`GetFeeHistoryReturnType`](https://viem.sh/docs/index.html)\>; `getFilterChanges`: \<`filterType`, `abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`GetFilterChangesReturnType`](https://viem.sh/docs/index.html)\<`filterType`, `abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>\>; `getFilterLogs`: \<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`GetFilterLogsReturnType`](https://viem.sh/docs/index.html)\<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>\>; `getGasPrice`: () => `Promise`\<`bigint`\>; `getLogs`: \<`abiEvent`, `abiEvents`, `strict`, `fromBlock`, `toBlock`\>(`args?`) => `Promise`\<[`GetLogsReturnType`](https://viem.sh/docs/index.html)\<`abiEvent`, `abiEvents`, `strict`, `fromBlock`, `toBlock`\>\>; `getProof`: (`args`) => `Promise`\<[`GetProofReturnType`](https://viem.sh/docs/index.html)\>; `getStorageAt`: (`args`) => `Promise`\<[`GetStorageAtReturnType`](https://viem.sh/docs/index.html)\>; `getTransaction`: \<`blockTag`\>(`args`) => `Promise`\<\{ `accessList?`: `undefined`; `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId?`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"legacy"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity?`: `undefined`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip2930"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip1559"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes`: readonly `` `0x${string}` ``[]; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas`: `bigint`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip4844"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList`: [`SignedAuthorizationList`](https://viem.sh/docs/index.html); `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip7702"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \}\>; `getTransactionConfirmations`: (`args`) => `Promise`\<`bigint`\>; `getTransactionCount`: (`args`) => `Promise`\<`number`\>; `getTransactionReceipt`: (`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>; `key`: `string`; `multicall`: \<`contracts`, `allowFailure`\>(`args`) => `Promise`\<[`MulticallReturnType`](https://viem.sh/docs/index.html)\<`contracts`, `allowFailure`\>\>; `name`: `string`; `pollingInterval`: `number`; `prepareTransactionRequest`: \<`request`, `chainOverride`, `accountOverride`\>(`args`) => `Promise`\<\{ \[K in string \| number \| symbol\]: (UnionRequiredBy\<Extract\<(...), (...)\> & \{ chainId?: ... \}, ParameterTypeToParameters\<(...) extends (...) ? (...) : (...)\>\> & (unknown extends request\["kzg"\] ? \{\} : Pick\<request, "kzg"\>))\[K\] \}\>; `readContract`: \<`abi`, `functionName`, `args`\>(`args`) => `Promise`\<[`ReadContractReturnType`](https://viem.sh/docs/index.html)\<`abi`, `functionName`, `args`\>\>; `request`: [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<[`PublicRpcSchema`](https://viem.sh/docs/index.html)\>; `sendRawTransaction`: (`args`) => `Promise`\<`` `0x${string}` ``\>; `sendRawTransactionSync`: (`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>; `simulate`: \<`calls`\>(`args`) => `Promise`\<[`SimulateBlocksReturnType`](https://viem.sh/docs/index.html)\<`calls`\>\>; `simulateBlocks`: \<`calls`\>(`args`) => `Promise`\<[`SimulateBlocksReturnType`](https://viem.sh/docs/index.html)\<`calls`\>\>; `simulateCalls`: \<`calls`\>(`args`) => `Promise`\<[`SimulateCallsReturnType`](https://viem.sh/docs/index.html)\<`calls`\>\>; `simulateContract`: \<`abi`, `functionName`, `args`, `chainOverride`, `accountOverride`\>(`args`) => `Promise`\<[`SimulateContractReturnType`](https://viem.sh/docs/index.html)\<`abi`, `functionName`, `args`, [`Chain`](https://viem.sh/docs/index.html) \| `undefined`, [`Account`](https://viem.sh/docs/index.html) \| `undefined`, `chainOverride`, `accountOverride`\>\>; `transport`: [`TransportConfig`](https://viem.sh/docs/index.html)\<`string`, [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\> & `Record`\<`string`, `any`\>; `type`: `string`; `uid`: `string`; `uninstallFilter`: (`args`) => `Promise`\<`boolean`\>; `verifyHash`: (`args`) => `Promise`\<`boolean`\>; `verifyMessage`: (`args`) => `Promise`\<`boolean`\>; `verifySiweMessage`: (`args`) => `Promise`\<`boolean`\>; `verifyTypedData`: (`args`) => `Promise`\<`boolean`\>; `waitForTransactionReceipt`: (`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>; `watchBlockNumber`: (`args`) => [`WatchBlockNumberReturnType`](https://viem.sh/docs/index.html); `watchBlocks`: \<`includeTransactions`, `blockTag`\>(`args`) => [`WatchBlocksReturnType`](https://viem.sh/docs/index.html); `watchContractEvent`: \<`abi`, `eventName`, `strict`\>(`args`) => [`WatchContractEventReturnType`](https://viem.sh/docs/index.html); `watchEvent`: \<`abiEvent`, `abiEvents`, `strict`\>(`args`) => [`WatchEventReturnType`](https://viem.sh/docs/index.html); `watchPendingTransactions`: (`args`) => [`WatchPendingTransactionsReturnType`](https://viem.sh/docs/index.html); \}
|
|
14
|
-
|
|
15
|
-
##### account
|
|
16
|
-
|
|
17
|
-
`undefined`
|
|
18
|
-
|
|
19
|
-
The Account of the Client.
|
|
20
|
-
|
|
21
|
-
##### batch?
|
|
22
|
-
|
|
23
|
-
\{ `multicall?`: `boolean` \| \{ `batchSize?`: `number`; `deployless?`: `boolean`; `wait?`: `number`; \}; \}
|
|
24
|
-
|
|
25
|
-
Flags for batch settings.
|
|
26
|
-
|
|
27
|
-
##### batch.multicall?
|
|
28
|
-
|
|
29
|
-
`boolean` \| \{ `batchSize?`: `number`; `deployless?`: `boolean`; `wait?`: `number`; \}
|
|
30
|
-
|
|
31
|
-
Toggle to enable `eth_call` multicall aggregation.
|
|
32
|
-
|
|
33
|
-
##### cacheTime
|
|
34
|
-
|
|
35
|
-
`number`
|
|
36
|
-
|
|
37
|
-
Time (in ms) that cached data will remain in memory.
|
|
38
|
-
|
|
39
|
-
##### call
|
|
40
|
-
|
|
41
|
-
(`parameters`) => `Promise`\<[`CallReturnType`](https://viem.sh/docs/index.html)\>
|
|
42
|
-
|
|
43
|
-
Executes a new message call immediately without submitting a transaction to the network.
|
|
44
|
-
|
|
45
|
-
- Docs: https://viem.sh/docs/actions/public/call
|
|
46
|
-
- JSON-RPC Methods: [`eth_call`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call)
|
|
47
|
-
|
|
48
|
-
**Example**
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
import { createPublicClient, http } from 'viem'
|
|
52
|
-
import { mainnet } from 'viem/chains'
|
|
53
|
-
|
|
54
|
-
const client = createPublicClient({
|
|
55
|
-
chain: mainnet,
|
|
56
|
-
transport: http(),
|
|
57
|
-
})
|
|
58
|
-
const data = await client.call({
|
|
59
|
-
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
60
|
-
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
61
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
62
|
-
})
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
##### ccipRead?
|
|
66
|
-
|
|
67
|
-
`false` \| \{ `request?`: (`parameters`) => `Promise`\<`` `0x${string}` ``\>; \}
|
|
68
|
-
|
|
69
|
-
[CCIP Read](https://eips.ethereum.org/EIPS/eip-3668) configuration.
|
|
70
|
-
|
|
71
|
-
##### chain
|
|
72
|
-
|
|
73
|
-
[`Chain`](https://viem.sh/docs/index.html) \| `undefined`
|
|
74
|
-
|
|
75
|
-
Chain for the client.
|
|
76
|
-
|
|
77
|
-
##### createAccessList
|
|
78
|
-
|
|
79
|
-
(`parameters`) => `Promise`\<\{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `gasUsed`: `bigint`; \}\>
|
|
80
|
-
|
|
81
|
-
Creates an EIP-2930 access list that you can include in a transaction.
|
|
82
|
-
|
|
83
|
-
- Docs: https://viem.sh/docs/actions/public/createAccessList
|
|
84
|
-
- JSON-RPC Methods: `eth_createAccessList`
|
|
85
|
-
|
|
86
|
-
**Example**
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
import { createPublicClient, http } from 'viem'
|
|
90
|
-
import { mainnet } from 'viem/chains'
|
|
91
|
-
|
|
92
|
-
const client = createPublicClient({
|
|
93
|
-
chain: mainnet,
|
|
94
|
-
transport: http(),
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
const data = await client.createAccessList({
|
|
98
|
-
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
99
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
100
|
-
})
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
##### createBlockFilter
|
|
104
|
-
|
|
105
|
-
() => `Promise`\<\{ `id`: `` `0x${string}` ``; `request`: [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<readonly \[\{ `Method`: `"eth_getFilterChanges"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: ...[] \| ...[]; \}, \{ `Method`: `"eth_getFilterLogs"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: [`RpcLog`](https://viem.sh/docs/index.html)[]; \}, \{ `Method`: `"eth_uninstallFilter"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: `boolean`; \}\]\>; `type`: `"block"`; \}\>
|
|
106
|
-
|
|
107
|
-
Creates a Filter to listen for new block hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).
|
|
108
|
-
|
|
109
|
-
- Docs: https://viem.sh/docs/actions/public/createBlockFilter
|
|
110
|
-
- JSON-RPC Methods: [`eth_newBlockFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newBlockFilter)
|
|
111
|
-
|
|
112
|
-
**Example**
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
import { createPublicClient, createBlockFilter, http } from 'viem'
|
|
116
|
-
import { mainnet } from 'viem/chains'
|
|
117
|
-
|
|
118
|
-
const client = createPublicClient({
|
|
119
|
-
chain: mainnet,
|
|
120
|
-
transport: http(),
|
|
121
|
-
})
|
|
122
|
-
const filter = await createBlockFilter(client)
|
|
123
|
-
// { id: "0x345a6572337856574a76364e457a4366", type: 'block' }
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
##### createContractEventFilter
|
|
127
|
-
|
|
128
|
-
\<`abi`, `eventName`, `args`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`CreateContractEventFilterReturnType`](https://viem.sh/docs/index.html)\<`abi`, `eventName`, `args`, `strict`, `fromBlock`, `toBlock`\>\>
|
|
129
|
-
|
|
130
|
-
Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs).
|
|
131
|
-
|
|
132
|
-
- Docs: https://viem.sh/docs/contract/createContractEventFilter
|
|
133
|
-
|
|
134
|
-
**Example**
|
|
135
|
-
|
|
136
|
-
```ts
|
|
137
|
-
import { createPublicClient, http, parseAbi } from 'viem'
|
|
138
|
-
import { mainnet } from 'viem/chains'
|
|
139
|
-
|
|
140
|
-
const client = createPublicClient({
|
|
141
|
-
chain: mainnet,
|
|
142
|
-
transport: http(),
|
|
143
|
-
})
|
|
144
|
-
const filter = await client.createContractEventFilter({
|
|
145
|
-
abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
|
|
146
|
-
})
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
##### createEventFilter
|
|
150
|
-
|
|
151
|
-
\<`abiEvent`, `abiEvents`, `strict`, `fromBlock`, `toBlock`, `_EventName`, `_Args`\>(`args?`) => `Promise`\<\{ \[K in string \| number \| symbol\]: Filter\<"event", abiEvents, \_EventName, \_Args, strict, fromBlock, toBlock\>\[K\] \}\>
|
|
152
|
-
|
|
153
|
-
Creates a [`Filter`](https://viem.sh/docs/glossary/types#filter) to listen for new events that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).
|
|
154
|
-
|
|
155
|
-
- Docs: https://viem.sh/docs/actions/public/createEventFilter
|
|
156
|
-
- JSON-RPC Methods: [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter)
|
|
157
|
-
|
|
158
|
-
**Example**
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
import { createPublicClient, http } from 'viem'
|
|
162
|
-
import { mainnet } from 'viem/chains'
|
|
163
|
-
|
|
164
|
-
const client = createPublicClient({
|
|
165
|
-
chain: mainnet,
|
|
166
|
-
transport: http(),
|
|
167
|
-
})
|
|
168
|
-
const filter = await client.createEventFilter({
|
|
169
|
-
address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',
|
|
170
|
-
})
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
##### createPendingTransactionFilter
|
|
174
|
-
|
|
175
|
-
() => `Promise`\<\{ `id`: `` `0x${string}` ``; `request`: [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<readonly \[\{ `Method`: `"eth_getFilterChanges"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: ...[] \| ...[]; \}, \{ `Method`: `"eth_getFilterLogs"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: [`RpcLog`](https://viem.sh/docs/index.html)[]; \}, \{ `Method`: `"eth_uninstallFilter"`; `Parameters`: \[`` `0x${(...)}` ``\]; `ReturnType`: `boolean`; \}\]\>; `type`: `"transaction"`; \}\>
|
|
176
|
-
|
|
177
|
-
Creates a Filter to listen for new pending transaction hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).
|
|
178
|
-
|
|
179
|
-
- Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter
|
|
180
|
-
- JSON-RPC Methods: [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter)
|
|
181
|
-
|
|
182
|
-
**Example**
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
import { createPublicClient, http } from 'viem'
|
|
186
|
-
import { mainnet } from 'viem/chains'
|
|
187
|
-
|
|
188
|
-
const client = createPublicClient({
|
|
189
|
-
chain: mainnet,
|
|
190
|
-
transport: http(),
|
|
191
|
-
})
|
|
192
|
-
const filter = await client.createPendingTransactionFilter()
|
|
193
|
-
// { id: "0x345a6572337856574a76364e457a4366", type: 'transaction' }
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
##### estimateContractGas
|
|
197
|
-
|
|
198
|
-
\<`chain`, `abi`, `functionName`, `args`\>(`args`) => `Promise`\<`bigint`\>
|
|
199
|
-
|
|
200
|
-
Estimates the gas required to successfully execute a contract write function call.
|
|
201
|
-
|
|
202
|
-
- Docs: https://viem.sh/docs/contract/estimateContractGas
|
|
203
|
-
|
|
204
|
-
**Remarks**
|
|
205
|
-
|
|
206
|
-
Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`estimateGas` action](https://viem.sh/docs/actions/public/estimateGas) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
|
207
|
-
|
|
208
|
-
**Example**
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
import { createPublicClient, http, parseAbi } from 'viem'
|
|
212
|
-
import { mainnet } from 'viem/chains'
|
|
213
|
-
|
|
214
|
-
const client = createPublicClient({
|
|
215
|
-
chain: mainnet,
|
|
216
|
-
transport: http(),
|
|
217
|
-
})
|
|
218
|
-
const gas = await client.estimateContractGas({
|
|
219
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
220
|
-
abi: parseAbi(['function mint() public']),
|
|
221
|
-
functionName: 'mint',
|
|
222
|
-
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
223
|
-
})
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
##### estimateFeesPerGas
|
|
227
|
-
|
|
228
|
-
\<`chainOverride`, `type`\>(`args?`) => `Promise`\<[`EstimateFeesPerGasReturnType`](https://viem.sh/docs/index.html)\<`type`\>\>
|
|
229
|
-
|
|
230
|
-
Returns an estimate for the fees per gas for a transaction to be included
|
|
231
|
-
in the next block.
|
|
232
|
-
|
|
233
|
-
- Docs: https://viem.sh/docs/actions/public/estimateFeesPerGas
|
|
234
|
-
|
|
235
|
-
**Example**
|
|
236
|
-
|
|
237
|
-
```ts
|
|
238
|
-
import { createPublicClient, http } from 'viem'
|
|
239
|
-
import { mainnet } from 'viem/chains'
|
|
240
|
-
|
|
241
|
-
const client = createPublicClient({
|
|
242
|
-
chain: mainnet,
|
|
243
|
-
transport: http(),
|
|
244
|
-
})
|
|
245
|
-
const maxPriorityFeePerGas = await client.estimateFeesPerGas()
|
|
246
|
-
// { maxFeePerGas: ..., maxPriorityFeePerGas: ... }
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
##### estimateGas
|
|
250
|
-
|
|
251
|
-
(`args`) => `Promise`\<`bigint`\>
|
|
252
|
-
|
|
253
|
-
Estimates the gas necessary to complete a transaction without submitting it to the network.
|
|
254
|
-
|
|
255
|
-
- Docs: https://viem.sh/docs/actions/public/estimateGas
|
|
256
|
-
- JSON-RPC Methods: [`eth_estimateGas`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)
|
|
257
|
-
|
|
258
|
-
**Example**
|
|
259
|
-
|
|
260
|
-
```ts
|
|
261
|
-
import { createPublicClient, http, parseEther } from 'viem'
|
|
262
|
-
import { mainnet } from 'viem/chains'
|
|
263
|
-
|
|
264
|
-
const client = createPublicClient({
|
|
265
|
-
chain: mainnet,
|
|
266
|
-
transport: http(),
|
|
267
|
-
})
|
|
268
|
-
const gasEstimate = await client.estimateGas({
|
|
269
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
270
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
271
|
-
value: parseEther('1'),
|
|
272
|
-
})
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
##### estimateMaxPriorityFeePerGas
|
|
276
|
-
|
|
277
|
-
\<`chainOverride`\>(`args?`) => `Promise`\<`bigint`\>
|
|
278
|
-
|
|
279
|
-
Returns an estimate for the max priority fee per gas (in wei) for a transaction
|
|
280
|
-
to be included in the next block.
|
|
281
|
-
|
|
282
|
-
- Docs: https://viem.sh/docs/actions/public/estimateMaxPriorityFeePerGas
|
|
283
|
-
|
|
284
|
-
**Example**
|
|
285
|
-
|
|
286
|
-
```ts
|
|
287
|
-
import { createPublicClient, http } from 'viem'
|
|
288
|
-
import { mainnet } from 'viem/chains'
|
|
289
|
-
|
|
290
|
-
const client = createPublicClient({
|
|
291
|
-
chain: mainnet,
|
|
292
|
-
transport: http(),
|
|
293
|
-
})
|
|
294
|
-
const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas()
|
|
295
|
-
// 10000000n
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
##### experimental_blockTag?
|
|
299
|
-
|
|
300
|
-
[`BlockTag`](https://viem.sh/docs/index.html)
|
|
301
|
-
|
|
302
|
-
Default block tag to use for RPC requests.
|
|
303
|
-
|
|
304
|
-
##### extend
|
|
305
|
-
|
|
306
|
-
\<`client`\>(`fn`) => [`Client`](https://viem.sh/docs/index.html)\<[`Transport`](https://viem.sh/docs/index.html), [`Chain`](https://viem.sh/docs/index.html) \| `undefined`, `undefined`, [`PublicRpcSchema`](https://viem.sh/docs/index.html), \{ \[K in string \| number \| symbol\]: client\[K\] \} & [`PublicActions`](https://viem.sh/docs/index.html)\<[`Transport`](https://viem.sh/docs/index.html), [`Chain`](https://viem.sh/docs/index.html) \| `undefined`\>\>
|
|
307
|
-
|
|
308
|
-
##### fillTransaction
|
|
309
|
-
|
|
310
|
-
\<`chainOverride`, `accountOverride`\>(`args`) => `Promise`\<[`FillTransactionReturnType`](https://viem.sh/docs/index.html)\<[`Chain`](https://viem.sh/docs/index.html) \| `undefined`, `chainOverride`\>\>
|
|
311
|
-
|
|
312
|
-
Fills a transaction request with the necessary fields to be signed over.
|
|
313
|
-
|
|
314
|
-
- Docs: https://viem.sh/docs/actions/public/fillTransaction
|
|
315
|
-
|
|
316
|
-
**Example**
|
|
317
|
-
|
|
318
|
-
```ts
|
|
319
|
-
import { createPublicClient, http } from 'viem'
|
|
320
|
-
import { mainnet } from 'viem/chains'
|
|
321
|
-
|
|
322
|
-
const client = createPublicClient({
|
|
323
|
-
chain: mainnet,
|
|
324
|
-
transport: http(),
|
|
325
|
-
})
|
|
326
|
-
const result = await client.fillTransaction({
|
|
327
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
328
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
329
|
-
value: parseEther('1'),
|
|
330
|
-
})
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
##### getBalance
|
|
334
|
-
|
|
335
|
-
(`args`) => `Promise`\<`bigint`\>
|
|
336
|
-
|
|
337
|
-
Returns the balance of an address in wei.
|
|
338
|
-
|
|
339
|
-
- Docs: https://viem.sh/docs/actions/public/getBalance
|
|
340
|
-
- JSON-RPC Methods: [`eth_getBalance`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance)
|
|
341
|
-
|
|
342
|
-
**Remarks**
|
|
343
|
-
|
|
344
|
-
You can convert the balance to ether units with [`formatEther`](https://viem.sh/docs/utilities/formatEther).
|
|
345
|
-
|
|
346
|
-
```ts
|
|
347
|
-
const balance = await getBalance(client, {
|
|
348
|
-
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
349
|
-
blockTag: 'safe'
|
|
350
|
-
})
|
|
351
|
-
const balanceAsEther = formatEther(balance)
|
|
352
|
-
// "6.942"
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
**Example**
|
|
356
|
-
|
|
357
|
-
```ts
|
|
358
|
-
import { createPublicClient, http } from 'viem'
|
|
359
|
-
import { mainnet } from 'viem/chains'
|
|
360
|
-
|
|
361
|
-
const client = createPublicClient({
|
|
362
|
-
chain: mainnet,
|
|
363
|
-
transport: http(),
|
|
364
|
-
})
|
|
365
|
-
const balance = await client.getBalance({
|
|
366
|
-
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
367
|
-
})
|
|
368
|
-
// 10000000000000000000000n (wei)
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
##### getBlobBaseFee
|
|
372
|
-
|
|
373
|
-
() => `Promise`\<`bigint`\>
|
|
374
|
-
|
|
375
|
-
Returns the base fee per blob gas in wei.
|
|
376
|
-
|
|
377
|
-
- Docs: https://viem.sh/docs/actions/public/getBlobBaseFee
|
|
378
|
-
- JSON-RPC Methods: [`eth_blobBaseFee`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blobBaseFee)
|
|
379
|
-
|
|
380
|
-
**Example**
|
|
381
|
-
|
|
382
|
-
```ts
|
|
383
|
-
import { createPublicClient, http } from 'viem'
|
|
384
|
-
import { mainnet } from 'viem/chains'
|
|
385
|
-
import { getBlobBaseFee } from 'viem/public'
|
|
386
|
-
|
|
387
|
-
const client = createPublicClient({
|
|
388
|
-
chain: mainnet,
|
|
389
|
-
transport: http(),
|
|
390
|
-
})
|
|
391
|
-
const blobBaseFee = await client.getBlobBaseFee()
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
##### getBlock
|
|
395
|
-
|
|
396
|
-
\<`includeTransactions`, `blockTag`\>(`args?`) => `Promise`\<\{ `baseFeePerGas`: `bigint` \| `null`; `blobGasUsed`: `bigint`; `difficulty`: `bigint`; `excessBlobGas`: `bigint`; `extraData`: `` `0x${string}` ``; `gasLimit`: `bigint`; `gasUsed`: `bigint`; `hash`: `blockTag` *extends* `"pending"` ? `null` : `` `0x${string}` ``; `logsBloom`: `blockTag` *extends* `"pending"` ? `null` : `` `0x${string}` ``; `miner`: `` `0x${string}` ``; `mixHash`: `` `0x${string}` ``; `nonce`: `blockTag` *extends* `"pending"` ? `null` : `` `0x${string}` ``; `number`: `blockTag` *extends* `"pending"` ? `null` : `bigint`; `parentBeaconBlockRoot?`: `` `0x${string}` ``; `parentHash`: `` `0x${string}` ``; `receiptsRoot`: `` `0x${string}` ``; `sealFields`: `` `0x${string}` ``[]; `sha3Uncles`: `` `0x${string}` ``; `size`: `bigint`; `stateRoot`: `` `0x${string}` ``; `timestamp`: `bigint`; `totalDifficulty`: `bigint` \| `null`; `transactions`: `includeTransactions` *extends* `true` ? (\{ `accessList?`: `undefined`; `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId?`: ... \| ...; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"legacy"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity?`: `undefined`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip2930"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip1559"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes`: readonly ...[]; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas`: `bigint`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip4844"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList`: [`SignedAuthorizationList`](https://viem.sh/docs/index.html); `blobVersionedHashes?`: `undefined`; `blockHash`: ... *extends* ... ? ... : ...; `blockNumber`: ... *extends* ... ? ... : ...; `chainId`: `number`; `from`: `` `0x${(...)}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${(...)}` ``; `input`: `` `0x${(...)}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${(...)}` ``; `s`: `` `0x${(...)}` ``; `to`: ... \| ...; `transactionIndex`: ... *extends* ... ? ... : ...; `type`: `"eip7702"`; `typeHex`: ... \| ...; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \})[] : `` `0x${string}` ``[]; `transactionsRoot`: `` `0x${string}` ``; `uncles`: `` `0x${string}` ``[]; `withdrawals?`: [`Withdrawal`](https://viem.sh/docs/index.html)[]; `withdrawalsRoot?`: `` `0x${string}` ``; \}\>
|
|
397
|
-
|
|
398
|
-
Returns information about a block at a block number, hash, or tag.
|
|
399
|
-
|
|
400
|
-
- Docs: https://viem.sh/docs/actions/public/getBlock
|
|
401
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks
|
|
402
|
-
- JSON-RPC Methods:
|
|
403
|
-
- Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) for `blockNumber` & `blockTag`.
|
|
404
|
-
- Calls [`eth_getBlockByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash) for `blockHash`.
|
|
405
|
-
|
|
406
|
-
**Example**
|
|
407
|
-
|
|
408
|
-
```ts
|
|
409
|
-
import { createPublicClient, http } from 'viem'
|
|
410
|
-
import { mainnet } from 'viem/chains'
|
|
411
|
-
|
|
412
|
-
const client = createPublicClient({
|
|
413
|
-
chain: mainnet,
|
|
414
|
-
transport: http(),
|
|
415
|
-
})
|
|
416
|
-
const block = await client.getBlock()
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
##### getBlockNumber
|
|
420
|
-
|
|
421
|
-
(`args?`) => `Promise`\<`bigint`\>
|
|
422
|
-
|
|
423
|
-
Returns the number of the most recent block seen.
|
|
424
|
-
|
|
425
|
-
- Docs: https://viem.sh/docs/actions/public/getBlockNumber
|
|
426
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks
|
|
427
|
-
- JSON-RPC Methods: [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber)
|
|
428
|
-
|
|
429
|
-
**Example**
|
|
430
|
-
|
|
431
|
-
```ts
|
|
432
|
-
import { createPublicClient, http } from 'viem'
|
|
433
|
-
import { mainnet } from 'viem/chains'
|
|
434
|
-
|
|
435
|
-
const client = createPublicClient({
|
|
436
|
-
chain: mainnet,
|
|
437
|
-
transport: http(),
|
|
438
|
-
})
|
|
439
|
-
const blockNumber = await client.getBlockNumber()
|
|
440
|
-
// 69420n
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
##### getBlockTransactionCount
|
|
444
|
-
|
|
445
|
-
(`args?`) => `Promise`\<`number`\>
|
|
446
|
-
|
|
447
|
-
Returns the number of Transactions at a block number, hash, or tag.
|
|
448
|
-
|
|
449
|
-
- Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount
|
|
450
|
-
- JSON-RPC Methods:
|
|
451
|
-
- Calls [`eth_getBlockTransactionCountByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber) for `blockNumber` & `blockTag`.
|
|
452
|
-
- Calls [`eth_getBlockTransactionCountByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash) for `blockHash`.
|
|
453
|
-
|
|
454
|
-
**Example**
|
|
455
|
-
|
|
456
|
-
```ts
|
|
457
|
-
import { createPublicClient, http } from 'viem'
|
|
458
|
-
import { mainnet } from 'viem/chains'
|
|
459
|
-
|
|
460
|
-
const client = createPublicClient({
|
|
461
|
-
chain: mainnet,
|
|
462
|
-
transport: http(),
|
|
463
|
-
})
|
|
464
|
-
const count = await client.getBlockTransactionCount()
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
##### getBytecode
|
|
468
|
-
|
|
469
|
-
(`args`) => `Promise`\<[`GetCodeReturnType`](https://viem.sh/docs/index.html)\>
|
|
470
|
-
|
|
471
|
-
**Deprecated**
|
|
472
|
-
|
|
473
|
-
Use `getCode` instead.
|
|
474
|
-
|
|
475
|
-
##### getChainId
|
|
476
|
-
|
|
477
|
-
() => `Promise`\<`number`\>
|
|
478
|
-
|
|
479
|
-
Returns the chain ID associated with the current network.
|
|
480
|
-
|
|
481
|
-
- Docs: https://viem.sh/docs/actions/public/getChainId
|
|
482
|
-
- JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)
|
|
483
|
-
|
|
484
|
-
**Example**
|
|
485
|
-
|
|
486
|
-
```ts
|
|
487
|
-
import { createPublicClient, http } from 'viem'
|
|
488
|
-
import { mainnet } from 'viem/chains'
|
|
489
|
-
|
|
490
|
-
const client = createPublicClient({
|
|
491
|
-
chain: mainnet,
|
|
492
|
-
transport: http(),
|
|
493
|
-
})
|
|
494
|
-
const chainId = await client.getChainId()
|
|
495
|
-
// 1
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
##### getCode
|
|
499
|
-
|
|
500
|
-
(`args`) => `Promise`\<[`GetCodeReturnType`](https://viem.sh/docs/index.html)\>
|
|
501
|
-
|
|
502
|
-
Retrieves the bytecode at an address.
|
|
503
|
-
|
|
504
|
-
- Docs: https://viem.sh/docs/contract/getCode
|
|
505
|
-
- JSON-RPC Methods: [`eth_getCode`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode)
|
|
506
|
-
|
|
507
|
-
**Example**
|
|
508
|
-
|
|
509
|
-
```ts
|
|
510
|
-
import { createPublicClient, http } from 'viem'
|
|
511
|
-
import { mainnet } from 'viem/chains'
|
|
512
|
-
|
|
513
|
-
const client = createPublicClient({
|
|
514
|
-
chain: mainnet,
|
|
515
|
-
transport: http(),
|
|
516
|
-
})
|
|
517
|
-
const code = await client.getCode({
|
|
518
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
519
|
-
})
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
##### getContractEvents
|
|
523
|
-
|
|
524
|
-
\<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`GetContractEventsReturnType`](https://viem.sh/docs/index.html)\<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>\>
|
|
525
|
-
|
|
526
|
-
Returns a list of event logs emitted by a contract.
|
|
527
|
-
|
|
528
|
-
- Docs: https://viem.sh/docs/actions/public/getContractEvents
|
|
529
|
-
- JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
|
530
|
-
|
|
531
|
-
**Example**
|
|
532
|
-
|
|
533
|
-
```ts
|
|
534
|
-
import { createPublicClient, http } from 'viem'
|
|
535
|
-
import { mainnet } from 'viem/chains'
|
|
536
|
-
import { wagmiAbi } from './abi'
|
|
537
|
-
|
|
538
|
-
const client = createPublicClient({
|
|
539
|
-
chain: mainnet,
|
|
540
|
-
transport: http(),
|
|
541
|
-
})
|
|
542
|
-
const logs = await client.getContractEvents(client, {
|
|
543
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
544
|
-
abi: wagmiAbi,
|
|
545
|
-
eventName: 'Transfer'
|
|
546
|
-
})
|
|
547
|
-
```
|
|
548
|
-
|
|
549
|
-
##### getEip712Domain
|
|
550
|
-
|
|
551
|
-
(`args`) => `Promise`\<[`GetEip712DomainReturnType`](https://viem.sh/docs/index.html)\>
|
|
552
|
-
|
|
553
|
-
Reads the EIP-712 domain from a contract, based on the ERC-5267 specification.
|
|
554
|
-
|
|
555
|
-
**Example**
|
|
556
|
-
|
|
557
|
-
```ts
|
|
558
|
-
import { createPublicClient, http } from 'viem'
|
|
559
|
-
import { mainnet } from 'viem/chains'
|
|
560
|
-
|
|
561
|
-
const client = createPublicClient({
|
|
562
|
-
chain: mainnet,
|
|
563
|
-
transport: http(),
|
|
564
|
-
})
|
|
565
|
-
|
|
566
|
-
const domain = await client.getEip712Domain({
|
|
567
|
-
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
568
|
-
})
|
|
569
|
-
// {
|
|
570
|
-
// domain: {
|
|
571
|
-
// name: 'ExampleContract',
|
|
572
|
-
// version: '1',
|
|
573
|
-
// chainId: 1,
|
|
574
|
-
// verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
575
|
-
// },
|
|
576
|
-
// fields: '0x0f',
|
|
577
|
-
// extensions: [],
|
|
578
|
-
// }
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
##### getEnsAddress
|
|
582
|
-
|
|
583
|
-
(`args`) => `Promise`\<[`GetEnsAddressReturnType`](https://viem.sh/docs/index.html)\>
|
|
584
|
-
|
|
585
|
-
Gets address for ENS name.
|
|
586
|
-
|
|
587
|
-
- Docs: https://viem.sh/docs/ens/actions/getEnsAddress
|
|
588
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
|
|
589
|
-
|
|
590
|
-
**Remarks**
|
|
591
|
-
|
|
592
|
-
Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.
|
|
593
|
-
|
|
594
|
-
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.
|
|
595
|
-
|
|
596
|
-
**Example**
|
|
597
|
-
|
|
598
|
-
```ts
|
|
599
|
-
import { createPublicClient, http } from 'viem'
|
|
600
|
-
import { mainnet } from 'viem/chains'
|
|
601
|
-
import { normalize } from 'viem/ens'
|
|
602
|
-
|
|
603
|
-
const client = createPublicClient({
|
|
604
|
-
chain: mainnet,
|
|
605
|
-
transport: http(),
|
|
606
|
-
})
|
|
607
|
-
const ensAddress = await client.getEnsAddress({
|
|
608
|
-
name: normalize('wevm.eth'),
|
|
609
|
-
})
|
|
610
|
-
// '0xd2135CfB216b74109775236E36d4b433F1DF507B'
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
##### getEnsAvatar
|
|
614
|
-
|
|
615
|
-
(`args`) => `Promise`\<[`GetEnsAvatarReturnType`](https://viem.sh/docs/index.html)\>
|
|
616
|
-
|
|
617
|
-
Gets the avatar of an ENS name.
|
|
618
|
-
|
|
619
|
-
- Docs: https://viem.sh/docs/ens/actions/getEnsAvatar
|
|
620
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
|
|
621
|
-
|
|
622
|
-
**Remarks**
|
|
623
|
-
|
|
624
|
-
Calls [`getEnsText`](https://viem.sh/docs/ens/actions/getEnsText) with `key` set to `'avatar'`.
|
|
625
|
-
|
|
626
|
-
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.
|
|
627
|
-
|
|
628
|
-
**Example**
|
|
629
|
-
|
|
630
|
-
```ts
|
|
631
|
-
import { createPublicClient, http } from 'viem'
|
|
632
|
-
import { mainnet } from 'viem/chains'
|
|
633
|
-
import { normalize } from 'viem/ens'
|
|
634
|
-
|
|
635
|
-
const client = createPublicClient({
|
|
636
|
-
chain: mainnet,
|
|
637
|
-
transport: http(),
|
|
638
|
-
})
|
|
639
|
-
const ensAvatar = await client.getEnsAvatar({
|
|
640
|
-
name: normalize('wevm.eth'),
|
|
641
|
-
})
|
|
642
|
-
// 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
##### getEnsName
|
|
646
|
-
|
|
647
|
-
(`args`) => `Promise`\<[`GetEnsNameReturnType`](https://viem.sh/docs/index.html)\>
|
|
648
|
-
|
|
649
|
-
Gets primary name for specified address.
|
|
650
|
-
|
|
651
|
-
- Docs: https://viem.sh/docs/ens/actions/getEnsName
|
|
652
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
|
|
653
|
-
|
|
654
|
-
**Remarks**
|
|
655
|
-
|
|
656
|
-
Calls `reverse(bytes)` on ENS Universal Resolver Contract to "reverse resolve" the address to the primary ENS name.
|
|
657
|
-
|
|
658
|
-
**Example**
|
|
659
|
-
|
|
660
|
-
```ts
|
|
661
|
-
import { createPublicClient, http } from 'viem'
|
|
662
|
-
import { mainnet } from 'viem/chains'
|
|
663
|
-
|
|
664
|
-
const client = createPublicClient({
|
|
665
|
-
chain: mainnet,
|
|
666
|
-
transport: http(),
|
|
667
|
-
})
|
|
668
|
-
const ensName = await client.getEnsName({
|
|
669
|
-
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
|
|
670
|
-
})
|
|
671
|
-
// 'wevm.eth'
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
##### getEnsResolver
|
|
675
|
-
|
|
676
|
-
(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
677
|
-
|
|
678
|
-
Gets resolver for ENS name.
|
|
679
|
-
|
|
680
|
-
- Docs: https://viem.sh/docs/ens/actions/getEnsResolver
|
|
681
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
|
|
682
|
-
|
|
683
|
-
**Remarks**
|
|
684
|
-
|
|
685
|
-
Calls `findResolver(bytes)` on ENS Universal Resolver Contract to retrieve the resolver of an ENS name.
|
|
686
|
-
|
|
687
|
-
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.
|
|
688
|
-
|
|
689
|
-
**Example**
|
|
690
|
-
|
|
691
|
-
```ts
|
|
692
|
-
import { createPublicClient, http } from 'viem'
|
|
693
|
-
import { mainnet } from 'viem/chains'
|
|
694
|
-
import { normalize } from 'viem/ens'
|
|
695
|
-
|
|
696
|
-
const client = createPublicClient({
|
|
697
|
-
chain: mainnet,
|
|
698
|
-
transport: http(),
|
|
699
|
-
})
|
|
700
|
-
const resolverAddress = await client.getEnsResolver({
|
|
701
|
-
name: normalize('wevm.eth'),
|
|
702
|
-
})
|
|
703
|
-
// '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
##### getEnsText
|
|
707
|
-
|
|
708
|
-
(`args`) => `Promise`\<[`GetEnsTextReturnType`](https://viem.sh/docs/index.html)\>
|
|
709
|
-
|
|
710
|
-
Gets a text record for specified ENS name.
|
|
711
|
-
|
|
712
|
-
- Docs: https://viem.sh/docs/ens/actions/getEnsResolver
|
|
713
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens
|
|
714
|
-
|
|
715
|
-
**Remarks**
|
|
716
|
-
|
|
717
|
-
Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.
|
|
718
|
-
|
|
719
|
-
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.
|
|
720
|
-
|
|
721
|
-
**Example**
|
|
722
|
-
|
|
723
|
-
```ts
|
|
724
|
-
import { createPublicClient, http } from 'viem'
|
|
725
|
-
import { mainnet } from 'viem/chains'
|
|
726
|
-
import { normalize } from 'viem/ens'
|
|
727
|
-
|
|
728
|
-
const client = createPublicClient({
|
|
729
|
-
chain: mainnet,
|
|
730
|
-
transport: http(),
|
|
731
|
-
})
|
|
732
|
-
const twitterRecord = await client.getEnsText({
|
|
733
|
-
name: normalize('wevm.eth'),
|
|
734
|
-
key: 'com.twitter',
|
|
735
|
-
})
|
|
736
|
-
// 'wevm_dev'
|
|
737
|
-
```
|
|
738
|
-
|
|
739
|
-
##### getFeeHistory
|
|
740
|
-
|
|
741
|
-
(`args`) => `Promise`\<[`GetFeeHistoryReturnType`](https://viem.sh/docs/index.html)\>
|
|
742
|
-
|
|
743
|
-
Returns a collection of historical gas information.
|
|
744
|
-
|
|
745
|
-
- Docs: https://viem.sh/docs/actions/public/getFeeHistory
|
|
746
|
-
- JSON-RPC Methods: [`eth_feeHistory`](https://docs.alchemy.com/reference/eth-feehistory)
|
|
747
|
-
|
|
748
|
-
**Example**
|
|
749
|
-
|
|
750
|
-
```ts
|
|
751
|
-
import { createPublicClient, http } from 'viem'
|
|
752
|
-
import { mainnet } from 'viem/chains'
|
|
753
|
-
|
|
754
|
-
const client = createPublicClient({
|
|
755
|
-
chain: mainnet,
|
|
756
|
-
transport: http(),
|
|
757
|
-
})
|
|
758
|
-
const feeHistory = await client.getFeeHistory({
|
|
759
|
-
blockCount: 4,
|
|
760
|
-
rewardPercentiles: [25, 75],
|
|
761
|
-
})
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
##### getFilterChanges
|
|
765
|
-
|
|
766
|
-
\<`filterType`, `abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`GetFilterChangesReturnType`](https://viem.sh/docs/index.html)\<`filterType`, `abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>\>
|
|
767
|
-
|
|
768
|
-
Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.
|
|
769
|
-
|
|
770
|
-
- Docs: https://viem.sh/docs/actions/public/getFilterChanges
|
|
771
|
-
- JSON-RPC Methods: [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)
|
|
772
|
-
|
|
773
|
-
**Remarks**
|
|
774
|
-
|
|
775
|
-
A Filter can be created from the following actions:
|
|
776
|
-
|
|
777
|
-
- [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
|
778
|
-
- [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)
|
|
779
|
-
- [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
|
780
|
-
- [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
|
781
|
-
|
|
782
|
-
Depending on the type of filter, the return value will be different:
|
|
783
|
-
|
|
784
|
-
- If the filter was created with `createContractEventFilter` or `createEventFilter`, it returns a list of logs.
|
|
785
|
-
- If the filter was created with `createPendingTransactionFilter`, it returns a list of transaction hashes.
|
|
786
|
-
- If the filter was created with `createBlockFilter`, it returns a list of block hashes.
|
|
787
|
-
|
|
788
|
-
**Examples**
|
|
789
|
-
|
|
790
|
-
```ts
|
|
791
|
-
// Blocks
|
|
792
|
-
import { createPublicClient, http } from 'viem'
|
|
793
|
-
import { mainnet } from 'viem/chains'
|
|
794
|
-
|
|
795
|
-
const client = createPublicClient({
|
|
796
|
-
chain: mainnet,
|
|
797
|
-
transport: http(),
|
|
798
|
-
})
|
|
799
|
-
const filter = await client.createBlockFilter()
|
|
800
|
-
const hashes = await client.getFilterChanges({ filter })
|
|
801
|
-
```
|
|
802
|
-
|
|
803
|
-
```ts
|
|
804
|
-
// Contract Events
|
|
805
|
-
import { createPublicClient, http, parseAbi } from 'viem'
|
|
806
|
-
import { mainnet } from 'viem/chains'
|
|
807
|
-
|
|
808
|
-
const client = createPublicClient({
|
|
809
|
-
chain: mainnet,
|
|
810
|
-
transport: http(),
|
|
811
|
-
})
|
|
812
|
-
const filter = await client.createContractEventFilter({
|
|
813
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
814
|
-
abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),
|
|
815
|
-
eventName: 'Transfer',
|
|
816
|
-
})
|
|
817
|
-
const logs = await client.getFilterChanges({ filter })
|
|
818
|
-
```
|
|
819
|
-
|
|
820
|
-
```ts
|
|
821
|
-
// Raw Events
|
|
822
|
-
import { createPublicClient, http, parseAbiItem } from 'viem'
|
|
823
|
-
import { mainnet } from 'viem/chains'
|
|
824
|
-
|
|
825
|
-
const client = createPublicClient({
|
|
826
|
-
chain: mainnet,
|
|
827
|
-
transport: http(),
|
|
828
|
-
})
|
|
829
|
-
const filter = await client.createEventFilter({
|
|
830
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
831
|
-
event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
|
|
832
|
-
})
|
|
833
|
-
const logs = await client.getFilterChanges({ filter })
|
|
834
|
-
```
|
|
835
|
-
|
|
836
|
-
```ts
|
|
837
|
-
// Transactions
|
|
838
|
-
import { createPublicClient, http } from 'viem'
|
|
839
|
-
import { mainnet } from 'viem/chains'
|
|
840
|
-
|
|
841
|
-
const client = createPublicClient({
|
|
842
|
-
chain: mainnet,
|
|
843
|
-
transport: http(),
|
|
844
|
-
})
|
|
845
|
-
const filter = await client.createPendingTransactionFilter()
|
|
846
|
-
const hashes = await client.getFilterChanges({ filter })
|
|
847
|
-
```
|
|
848
|
-
|
|
849
|
-
##### getFilterLogs
|
|
850
|
-
|
|
851
|
-
\<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>(`args`) => `Promise`\<[`GetFilterLogsReturnType`](https://viem.sh/docs/index.html)\<`abi`, `eventName`, `strict`, `fromBlock`, `toBlock`\>\>
|
|
852
|
-
|
|
853
|
-
Returns a list of event logs since the filter was created.
|
|
854
|
-
|
|
855
|
-
- Docs: https://viem.sh/docs/actions/public/getFilterLogs
|
|
856
|
-
- JSON-RPC Methods: [`eth_getFilterLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterlogs)
|
|
857
|
-
|
|
858
|
-
**Remarks**
|
|
859
|
-
|
|
860
|
-
`getFilterLogs` is only compatible with **event filters**.
|
|
861
|
-
|
|
862
|
-
**Example**
|
|
863
|
-
|
|
864
|
-
```ts
|
|
865
|
-
import { createPublicClient, http, parseAbiItem } from 'viem'
|
|
866
|
-
import { mainnet } from 'viem/chains'
|
|
867
|
-
|
|
868
|
-
const client = createPublicClient({
|
|
869
|
-
chain: mainnet,
|
|
870
|
-
transport: http(),
|
|
871
|
-
})
|
|
872
|
-
const filter = await client.createEventFilter({
|
|
873
|
-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
874
|
-
event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),
|
|
875
|
-
})
|
|
876
|
-
const logs = await client.getFilterLogs({ filter })
|
|
877
|
-
```
|
|
878
|
-
|
|
879
|
-
##### getGasPrice
|
|
880
|
-
|
|
881
|
-
() => `Promise`\<`bigint`\>
|
|
882
|
-
|
|
883
|
-
Returns the current price of gas (in wei).
|
|
884
|
-
|
|
885
|
-
- Docs: https://viem.sh/docs/actions/public/getGasPrice
|
|
886
|
-
- JSON-RPC Methods: [`eth_gasPrice`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice)
|
|
887
|
-
|
|
888
|
-
**Example**
|
|
889
|
-
|
|
890
|
-
```ts
|
|
891
|
-
import { createPublicClient, http } from 'viem'
|
|
892
|
-
import { mainnet } from 'viem/chains'
|
|
893
|
-
|
|
894
|
-
const client = createPublicClient({
|
|
895
|
-
chain: mainnet,
|
|
896
|
-
transport: http(),
|
|
897
|
-
})
|
|
898
|
-
const gasPrice = await client.getGasPrice()
|
|
899
|
-
```
|
|
900
|
-
|
|
901
|
-
##### getLogs
|
|
902
|
-
|
|
903
|
-
\<`abiEvent`, `abiEvents`, `strict`, `fromBlock`, `toBlock`\>(`args?`) => `Promise`\<[`GetLogsReturnType`](https://viem.sh/docs/index.html)\<`abiEvent`, `abiEvents`, `strict`, `fromBlock`, `toBlock`\>\>
|
|
904
|
-
|
|
905
|
-
Returns a list of event logs matching the provided parameters.
|
|
906
|
-
|
|
907
|
-
- Docs: https://viem.sh/docs/actions/public/getLogs
|
|
908
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/logs_event-logs
|
|
909
|
-
- JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)
|
|
910
|
-
|
|
911
|
-
**Example**
|
|
912
|
-
|
|
913
|
-
```ts
|
|
914
|
-
import { createPublicClient, http, parseAbiItem } from 'viem'
|
|
915
|
-
import { mainnet } from 'viem/chains'
|
|
916
|
-
|
|
917
|
-
const client = createPublicClient({
|
|
918
|
-
chain: mainnet,
|
|
919
|
-
transport: http(),
|
|
920
|
-
})
|
|
921
|
-
const logs = await client.getLogs()
|
|
922
|
-
```
|
|
923
|
-
|
|
924
|
-
##### getProof
|
|
925
|
-
|
|
926
|
-
(`args`) => `Promise`\<[`GetProofReturnType`](https://viem.sh/docs/index.html)\>
|
|
927
|
-
|
|
928
|
-
Returns the account and storage values of the specified account including the Merkle-proof.
|
|
929
|
-
|
|
930
|
-
- Docs: https://viem.sh/docs/actions/public/getProof
|
|
931
|
-
- JSON-RPC Methods:
|
|
932
|
-
- Calls [`eth_getProof`](https://eips.ethereum.org/EIPS/eip-1186)
|
|
933
|
-
|
|
934
|
-
**Example**
|
|
935
|
-
|
|
936
|
-
```ts
|
|
937
|
-
import { createPublicClient, http } from 'viem'
|
|
938
|
-
import { mainnet } from 'viem/chains'
|
|
939
|
-
|
|
940
|
-
const client = createPublicClient({
|
|
941
|
-
chain: mainnet,
|
|
942
|
-
transport: http(),
|
|
943
|
-
})
|
|
944
|
-
const block = await client.getProof({
|
|
945
|
-
address: '0x...',
|
|
946
|
-
storageKeys: ['0x...'],
|
|
947
|
-
})
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
##### getStorageAt
|
|
951
|
-
|
|
952
|
-
(`args`) => `Promise`\<[`GetStorageAtReturnType`](https://viem.sh/docs/index.html)\>
|
|
953
|
-
|
|
954
|
-
Returns the value from a storage slot at a given address.
|
|
955
|
-
|
|
956
|
-
- Docs: https://viem.sh/docs/contract/getStorageAt
|
|
957
|
-
- JSON-RPC Methods: [`eth_getStorageAt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getstorageat)
|
|
958
|
-
|
|
959
|
-
**Example**
|
|
960
|
-
|
|
961
|
-
```ts
|
|
962
|
-
import { createPublicClient, http } from 'viem'
|
|
963
|
-
import { mainnet } from 'viem/chains'
|
|
964
|
-
import { getStorageAt } from 'viem/contract'
|
|
965
|
-
|
|
966
|
-
const client = createPublicClient({
|
|
967
|
-
chain: mainnet,
|
|
968
|
-
transport: http(),
|
|
969
|
-
})
|
|
970
|
-
const code = await client.getStorageAt({
|
|
971
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
972
|
-
slot: toHex(0),
|
|
973
|
-
})
|
|
974
|
-
```
|
|
975
|
-
|
|
976
|
-
##### getTransaction
|
|
977
|
-
|
|
978
|
-
\<`blockTag`\>(`args`) => `Promise`\<\{ `accessList?`: `undefined`; `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId?`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"legacy"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity?`: `undefined`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice`: `bigint`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas?`: `undefined`; `maxPriorityFeePerGas?`: `undefined`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip2930"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip1559"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList?`: `undefined`; `blobVersionedHashes`: readonly `` `0x${string}` ``[]; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas`: `bigint`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip4844"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \} \| \{ `accessList`: [`AccessList`](https://viem.sh/docs/index.html); `authorizationList`: [`SignedAuthorizationList`](https://viem.sh/docs/index.html); `blobVersionedHashes?`: `undefined`; `blockHash`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `` `0x${string}` ``; `blockNumber`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `bigint`; `chainId`: `number`; `from`: `` `0x${string}` ``; `gas`: `bigint`; `gasPrice?`: `undefined`; `hash`: `` `0x${string}` ``; `input`: `` `0x${string}` ``; `maxFeePerBlobGas?`: `undefined`; `maxFeePerGas`: `bigint`; `maxPriorityFeePerGas`: `bigint`; `nonce`: `number`; `r`: `` `0x${string}` ``; `s`: `` `0x${string}` ``; `to`: `` `0x${string}` `` \| `null`; `transactionIndex`: `blockTag` *extends* `"pending"` ? `true` : `false` *extends* `true` ? `null` : `number`; `type`: `"eip7702"`; `typeHex`: `` `0x${string}` `` \| `null`; `v`: `bigint`; `value`: `bigint`; `yParity`: `number`; \}\>
|
|
979
|
-
|
|
980
|
-
Returns information about a [Transaction](https://viem.sh/docs/glossary/terms#transaction) given a hash or block identifier.
|
|
981
|
-
|
|
982
|
-
- Docs: https://viem.sh/docs/actions/public/getTransaction
|
|
983
|
-
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions
|
|
984
|
-
- JSON-RPC Methods: [`eth_getTransactionByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionByHash)
|
|
985
|
-
|
|
986
|
-
**Example**
|
|
987
|
-
|
|
988
|
-
```ts
|
|
989
|
-
import { createPublicClient, http } from 'viem'
|
|
990
|
-
import { mainnet } from 'viem/chains'
|
|
991
|
-
|
|
992
|
-
const client = createPublicClient({
|
|
993
|
-
chain: mainnet,
|
|
994
|
-
transport: http(),
|
|
995
|
-
})
|
|
996
|
-
const transaction = await client.getTransaction({
|
|
997
|
-
hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
998
|
-
})
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
##### getTransactionConfirmations
|
|
1002
|
-
|
|
1003
|
-
(`args`) => `Promise`\<`bigint`\>
|
|
1004
|
-
|
|
1005
|
-
Returns the number of blocks passed (confirmations) since the transaction was processed on a block.
|
|
1006
|
-
|
|
1007
|
-
- Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations
|
|
1008
|
-
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions
|
|
1009
|
-
- JSON-RPC Methods: [`eth_getTransactionConfirmations`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionConfirmations)
|
|
1010
|
-
|
|
1011
|
-
**Example**
|
|
1012
|
-
|
|
1013
|
-
```ts
|
|
1014
|
-
import { createPublicClient, http } from 'viem'
|
|
1015
|
-
import { mainnet } from 'viem/chains'
|
|
1016
|
-
|
|
1017
|
-
const client = createPublicClient({
|
|
1018
|
-
chain: mainnet,
|
|
1019
|
-
transport: http(),
|
|
1020
|
-
})
|
|
1021
|
-
const confirmations = await client.getTransactionConfirmations({
|
|
1022
|
-
hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
1023
|
-
})
|
|
1024
|
-
```
|
|
1025
|
-
|
|
1026
|
-
##### getTransactionCount
|
|
1027
|
-
|
|
1028
|
-
(`args`) => `Promise`\<`number`\>
|
|
1029
|
-
|
|
1030
|
-
Returns the number of [Transactions](https://viem.sh/docs/glossary/terms#transaction) an Account has broadcast / sent.
|
|
1031
|
-
|
|
1032
|
-
- Docs: https://viem.sh/docs/actions/public/getTransactionCount
|
|
1033
|
-
- JSON-RPC Methods: [`eth_getTransactionCount`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactioncount)
|
|
1034
|
-
|
|
1035
|
-
**Example**
|
|
1036
|
-
|
|
1037
|
-
```ts
|
|
1038
|
-
import { createPublicClient, http } from 'viem'
|
|
1039
|
-
import { mainnet } from 'viem/chains'
|
|
1040
|
-
|
|
1041
|
-
const client = createPublicClient({
|
|
1042
|
-
chain: mainnet,
|
|
1043
|
-
transport: http(),
|
|
1044
|
-
})
|
|
1045
|
-
const transactionCount = await client.getTransactionCount({
|
|
1046
|
-
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1047
|
-
})
|
|
1048
|
-
```
|
|
1049
|
-
|
|
1050
|
-
##### getTransactionReceipt
|
|
1051
|
-
|
|
1052
|
-
(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>
|
|
1053
|
-
|
|
1054
|
-
Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.
|
|
1055
|
-
|
|
1056
|
-
- Docs: https://viem.sh/docs/actions/public/getTransactionReceipt
|
|
1057
|
-
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions
|
|
1058
|
-
- JSON-RPC Methods: [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt)
|
|
1059
|
-
|
|
1060
|
-
**Example**
|
|
1061
|
-
|
|
1062
|
-
```ts
|
|
1063
|
-
import { createPublicClient, http } from 'viem'
|
|
1064
|
-
import { mainnet } from 'viem/chains'
|
|
1065
|
-
|
|
1066
|
-
const client = createPublicClient({
|
|
1067
|
-
chain: mainnet,
|
|
1068
|
-
transport: http(),
|
|
1069
|
-
})
|
|
1070
|
-
const transactionReceipt = await client.getTransactionReceipt({
|
|
1071
|
-
hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
1072
|
-
})
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
|
-
##### key
|
|
1076
|
-
|
|
1077
|
-
`string`
|
|
1078
|
-
|
|
1079
|
-
A key for the client.
|
|
1080
|
-
|
|
1081
|
-
##### multicall
|
|
1082
|
-
|
|
1083
|
-
\<`contracts`, `allowFailure`\>(`args`) => `Promise`\<[`MulticallReturnType`](https://viem.sh/docs/index.html)\<`contracts`, `allowFailure`\>\>
|
|
1084
|
-
|
|
1085
|
-
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).
|
|
1086
|
-
|
|
1087
|
-
- Docs: https://viem.sh/docs/contract/multicall
|
|
1088
|
-
|
|
1089
|
-
**Example**
|
|
1090
|
-
|
|
1091
|
-
```ts
|
|
1092
|
-
import { createPublicClient, http, parseAbi } from 'viem'
|
|
1093
|
-
import { mainnet } from 'viem/chains'
|
|
1094
|
-
|
|
1095
|
-
const client = createPublicClient({
|
|
1096
|
-
chain: mainnet,
|
|
1097
|
-
transport: http(),
|
|
1098
|
-
})
|
|
1099
|
-
const abi = parseAbi([
|
|
1100
|
-
'function balanceOf(address) view returns (uint256)',
|
|
1101
|
-
'function totalSupply() view returns (uint256)',
|
|
1102
|
-
])
|
|
1103
|
-
const result = await client.multicall({
|
|
1104
|
-
contracts: [
|
|
1105
|
-
{
|
|
1106
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1107
|
-
abi,
|
|
1108
|
-
functionName: 'balanceOf',
|
|
1109
|
-
args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
|
|
1110
|
-
},
|
|
1111
|
-
{
|
|
1112
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1113
|
-
abi,
|
|
1114
|
-
functionName: 'totalSupply',
|
|
1115
|
-
},
|
|
1116
|
-
],
|
|
1117
|
-
})
|
|
1118
|
-
// [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
|
|
1119
|
-
```
|
|
1120
|
-
|
|
1121
|
-
##### name
|
|
1122
|
-
|
|
1123
|
-
`string`
|
|
1124
|
-
|
|
1125
|
-
A name for the client.
|
|
1126
|
-
|
|
1127
|
-
##### pollingInterval
|
|
1128
|
-
|
|
1129
|
-
`number`
|
|
1130
|
-
|
|
1131
|
-
Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
|
|
1132
|
-
|
|
1133
|
-
##### prepareTransactionRequest
|
|
1134
|
-
|
|
1135
|
-
\<`request`, `chainOverride`, `accountOverride`\>(`args`) => `Promise`\<\{ \[K in string \| number \| symbol\]: (UnionRequiredBy\<Extract\<(...), (...)\> & \{ chainId?: ... \}, ParameterTypeToParameters\<(...) extends (...) ? (...) : (...)\>\> & (unknown extends request\["kzg"\] ? \{\} : Pick\<request, "kzg"\>))\[K\] \}\>
|
|
1136
|
-
|
|
1137
|
-
Prepares a transaction request for signing.
|
|
1138
|
-
|
|
1139
|
-
- Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest
|
|
1140
|
-
|
|
1141
|
-
**Examples**
|
|
1142
|
-
|
|
1143
|
-
```ts
|
|
1144
|
-
import { createWalletClient, custom } from 'viem'
|
|
1145
|
-
import { mainnet } from 'viem/chains'
|
|
1146
|
-
|
|
1147
|
-
const client = createWalletClient({
|
|
1148
|
-
chain: mainnet,
|
|
1149
|
-
transport: custom(window.ethereum),
|
|
1150
|
-
})
|
|
1151
|
-
const request = await client.prepareTransactionRequest({
|
|
1152
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1153
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
1154
|
-
value: 1n,
|
|
1155
|
-
})
|
|
1156
|
-
```
|
|
1157
|
-
|
|
1158
|
-
```ts
|
|
1159
|
-
// Account Hoisting
|
|
1160
|
-
import { createWalletClient, http } from 'viem'
|
|
1161
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
1162
|
-
import { mainnet } from 'viem/chains'
|
|
1163
|
-
|
|
1164
|
-
const client = createWalletClient({
|
|
1165
|
-
account: privateKeyToAccount('0x…'),
|
|
1166
|
-
chain: mainnet,
|
|
1167
|
-
transport: custom(window.ethereum),
|
|
1168
|
-
})
|
|
1169
|
-
const request = await client.prepareTransactionRequest({
|
|
1170
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
1171
|
-
value: 1n,
|
|
1172
|
-
})
|
|
1173
|
-
```
|
|
1174
|
-
|
|
1175
|
-
##### readContract
|
|
1176
|
-
|
|
1177
|
-
\<`abi`, `functionName`, `args`\>(`args`) => `Promise`\<[`ReadContractReturnType`](https://viem.sh/docs/index.html)\<`abi`, `functionName`, `args`\>\>
|
|
1178
|
-
|
|
1179
|
-
Calls a read-only function on a contract, and returns the response.
|
|
1180
|
-
|
|
1181
|
-
- Docs: https://viem.sh/docs/contract/readContract
|
|
1182
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_reading-contracts
|
|
1183
|
-
|
|
1184
|
-
**Remarks**
|
|
1185
|
-
|
|
1186
|
-
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.
|
|
1187
|
-
|
|
1188
|
-
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).
|
|
1189
|
-
|
|
1190
|
-
**Example**
|
|
1191
|
-
|
|
1192
|
-
```ts
|
|
1193
|
-
import { createPublicClient, http, parseAbi } from 'viem'
|
|
1194
|
-
import { mainnet } from 'viem/chains'
|
|
1195
|
-
import { readContract } from 'viem/contract'
|
|
1196
|
-
|
|
1197
|
-
const client = createPublicClient({
|
|
1198
|
-
chain: mainnet,
|
|
1199
|
-
transport: http(),
|
|
1200
|
-
})
|
|
1201
|
-
const result = await client.readContract({
|
|
1202
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1203
|
-
abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
|
|
1204
|
-
functionName: 'balanceOf',
|
|
1205
|
-
args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],
|
|
1206
|
-
})
|
|
1207
|
-
// 424122n
|
|
1208
|
-
```
|
|
1209
|
-
|
|
1210
|
-
##### request
|
|
1211
|
-
|
|
1212
|
-
[`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<[`PublicRpcSchema`](https://viem.sh/docs/index.html)\>
|
|
1213
|
-
|
|
1214
|
-
Request function wrapped with friendly error handling
|
|
1215
|
-
|
|
1216
|
-
##### sendRawTransaction
|
|
1217
|
-
|
|
1218
|
-
(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
1219
|
-
|
|
1220
|
-
Sends a **signed** transaction to the network
|
|
1221
|
-
|
|
1222
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction
|
|
1223
|
-
- JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
|
1224
|
-
|
|
1225
|
-
**Example**
|
|
1226
|
-
|
|
1227
|
-
```ts
|
|
1228
|
-
import { createWalletClient, custom } from 'viem'
|
|
1229
|
-
import { mainnet } from 'viem/chains'
|
|
1230
|
-
import { sendRawTransaction } from 'viem/wallet'
|
|
1231
|
-
|
|
1232
|
-
const client = createWalletClient({
|
|
1233
|
-
chain: mainnet,
|
|
1234
|
-
transport: custom(window.ethereum),
|
|
1235
|
-
})
|
|
1236
|
-
|
|
1237
|
-
const hash = await client.sendRawTransaction({
|
|
1238
|
-
serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
1239
|
-
})
|
|
1240
|
-
```
|
|
1241
|
-
|
|
1242
|
-
##### sendRawTransactionSync
|
|
1243
|
-
|
|
1244
|
-
(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>
|
|
1245
|
-
|
|
1246
|
-
Sends a **signed** transaction to the network
|
|
1247
|
-
|
|
1248
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync
|
|
1249
|
-
- JSON-RPC Method: [`eth_sendRawTransactionSync`](https://eips.ethereum.org/EIPS/eip-7966)
|
|
1250
|
-
|
|
1251
|
-
**Example**
|
|
1252
|
-
|
|
1253
|
-
```ts
|
|
1254
|
-
import { createWalletClient, custom } from 'viem'
|
|
1255
|
-
import { mainnet } from 'viem/chains'
|
|
1256
|
-
import { sendRawTransactionSync } from 'viem/wallet'
|
|
1257
|
-
|
|
1258
|
-
const client = createWalletClient({
|
|
1259
|
-
chain: mainnet,
|
|
1260
|
-
transport: custom(window.ethereum),
|
|
1261
|
-
})
|
|
1262
|
-
|
|
1263
|
-
const receipt = await client.sendRawTransactionSync({
|
|
1264
|
-
serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
1265
|
-
})
|
|
1266
|
-
```
|
|
1267
|
-
|
|
1268
|
-
##### simulate
|
|
1269
|
-
|
|
1270
|
-
\<`calls`\>(`args`) => `Promise`\<[`SimulateBlocksReturnType`](https://viem.sh/docs/index.html)\<`calls`\>\>
|
|
1271
|
-
|
|
1272
|
-
**Deprecated**
|
|
1273
|
-
|
|
1274
|
-
Use `simulateBlocks` instead.
|
|
1275
|
-
|
|
1276
|
-
##### simulateBlocks
|
|
1277
|
-
|
|
1278
|
-
\<`calls`\>(`args`) => `Promise`\<[`SimulateBlocksReturnType`](https://viem.sh/docs/index.html)\<`calls`\>\>
|
|
1279
|
-
|
|
1280
|
-
Simulates a set of calls on block(s) with optional block and state overrides.
|
|
1281
|
-
|
|
1282
|
-
**Example**
|
|
1283
|
-
|
|
1284
|
-
```ts
|
|
1285
|
-
import { createPublicClient, http, parseEther } from 'viem'
|
|
1286
|
-
import { mainnet } from 'viem/chains'
|
|
1287
|
-
|
|
1288
|
-
const client = createPublicClient({
|
|
1289
|
-
chain: mainnet,
|
|
1290
|
-
transport: http(),
|
|
1291
|
-
})
|
|
1292
|
-
|
|
1293
|
-
const result = await client.simulateBlocks({
|
|
1294
|
-
blocks: [{
|
|
1295
|
-
blockOverrides: {
|
|
1296
|
-
number: 69420n,
|
|
1297
|
-
},
|
|
1298
|
-
calls: [{
|
|
1299
|
-
{
|
|
1300
|
-
account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',
|
|
1301
|
-
data: '0xdeadbeef',
|
|
1302
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
1303
|
-
},
|
|
1304
|
-
{
|
|
1305
|
-
account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',
|
|
1306
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
1307
|
-
value: parseEther('1'),
|
|
1308
|
-
},
|
|
1309
|
-
}],
|
|
1310
|
-
stateOverrides: [{
|
|
1311
|
-
address: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',
|
|
1312
|
-
balance: parseEther('10'),
|
|
1313
|
-
}],
|
|
1314
|
-
}]
|
|
1315
|
-
})
|
|
1316
|
-
```
|
|
1317
|
-
|
|
1318
|
-
##### simulateCalls
|
|
1319
|
-
|
|
1320
|
-
\<`calls`\>(`args`) => `Promise`\<[`SimulateCallsReturnType`](https://viem.sh/docs/index.html)\<`calls`\>\>
|
|
1321
|
-
|
|
1322
|
-
Simulates a set of calls.
|
|
1323
|
-
|
|
1324
|
-
**Example**
|
|
1325
|
-
|
|
1326
|
-
```ts
|
|
1327
|
-
import { createPublicClient, http, parseEther } from 'viem'
|
|
1328
|
-
import { mainnet } from 'viem/chains'
|
|
1329
|
-
|
|
1330
|
-
const client = createPublicClient({
|
|
1331
|
-
chain: mainnet,
|
|
1332
|
-
transport: http(),
|
|
1333
|
-
})
|
|
1334
|
-
|
|
1335
|
-
const result = await client.simulateCalls({
|
|
1336
|
-
account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',
|
|
1337
|
-
calls: [{
|
|
1338
|
-
{
|
|
1339
|
-
data: '0xdeadbeef',
|
|
1340
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
1341
|
-
},
|
|
1342
|
-
{
|
|
1343
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
1344
|
-
value: parseEther('1'),
|
|
1345
|
-
},
|
|
1346
|
-
]
|
|
1347
|
-
})
|
|
1348
|
-
```
|
|
1349
|
-
|
|
1350
|
-
##### simulateContract
|
|
1351
|
-
|
|
1352
|
-
\<`abi`, `functionName`, `args`, `chainOverride`, `accountOverride`\>(`args`) => `Promise`\<[`SimulateContractReturnType`](https://viem.sh/docs/index.html)\<`abi`, `functionName`, `args`, [`Chain`](https://viem.sh/docs/index.html) \| `undefined`, [`Account`](https://viem.sh/docs/index.html) \| `undefined`, `chainOverride`, `accountOverride`\>\>
|
|
1353
|
-
|
|
1354
|
-
Simulates/validates a contract interaction. This is useful for retrieving **return data** and **revert reasons** of contract write functions.
|
|
1355
|
-
|
|
1356
|
-
- Docs: https://viem.sh/docs/contract/simulateContract
|
|
1357
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts
|
|
1358
|
-
|
|
1359
|
-
**Remarks**
|
|
1360
|
-
|
|
1361
|
-
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.
|
|
1362
|
-
|
|
1363
|
-
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).
|
|
1364
|
-
|
|
1365
|
-
**Example**
|
|
1366
|
-
|
|
1367
|
-
```ts
|
|
1368
|
-
import { createPublicClient, http } from 'viem'
|
|
1369
|
-
import { mainnet } from 'viem/chains'
|
|
1370
|
-
|
|
1371
|
-
const client = createPublicClient({
|
|
1372
|
-
chain: mainnet,
|
|
1373
|
-
transport: http(),
|
|
1374
|
-
})
|
|
1375
|
-
const result = await client.simulateContract({
|
|
1376
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1377
|
-
abi: parseAbi(['function mint(uint32) view returns (uint32)']),
|
|
1378
|
-
functionName: 'mint',
|
|
1379
|
-
args: ['69420'],
|
|
1380
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1381
|
-
})
|
|
1382
|
-
```
|
|
1383
|
-
|
|
1384
|
-
##### transport
|
|
1385
|
-
|
|
1386
|
-
[`TransportConfig`](https://viem.sh/docs/index.html)\<`string`, [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\> & `Record`\<`string`, `any`\>
|
|
1387
|
-
|
|
1388
|
-
The RPC transport
|
|
1389
|
-
|
|
1390
|
-
##### type
|
|
1391
|
-
|
|
1392
|
-
`string`
|
|
1393
|
-
|
|
1394
|
-
The type of client.
|
|
1395
|
-
|
|
1396
|
-
##### uid
|
|
1397
|
-
|
|
1398
|
-
`string`
|
|
1399
|
-
|
|
1400
|
-
A unique ID for the client.
|
|
1401
|
-
|
|
1402
|
-
##### uninstallFilter
|
|
1403
|
-
|
|
1404
|
-
(`args`) => `Promise`\<`boolean`\>
|
|
1405
|
-
|
|
1406
|
-
Destroys a Filter that was created from one of the following Actions:
|
|
1407
|
-
|
|
1408
|
-
- [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)
|
|
1409
|
-
- [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)
|
|
1410
|
-
- [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)
|
|
1411
|
-
|
|
1412
|
-
- Docs: https://viem.sh/docs/actions/public/uninstallFilter
|
|
1413
|
-
- JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)
|
|
1414
|
-
|
|
1415
|
-
**Example**
|
|
1416
|
-
|
|
1417
|
-
```ts
|
|
1418
|
-
import { createPublicClient, http } from 'viem'
|
|
1419
|
-
import { mainnet } from 'viem/chains'
|
|
1420
|
-
import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'
|
|
1421
|
-
|
|
1422
|
-
const filter = await client.createPendingTransactionFilter()
|
|
1423
|
-
const uninstalled = await client.uninstallFilter({ filter })
|
|
1424
|
-
// true
|
|
1425
|
-
```
|
|
1426
|
-
|
|
1427
|
-
##### verifyHash
|
|
1428
|
-
|
|
1429
|
-
(`args`) => `Promise`\<`boolean`\>
|
|
1430
|
-
|
|
1431
|
-
Verify that a hash was signed by the provided address.
|
|
1432
|
-
|
|
1433
|
-
- Docs [https://viem.sh/docs/actions/public/verifyHash](https://viem.sh/docs/actions/public/verifyHash)
|
|
1434
|
-
|
|
1435
|
-
##### verifyMessage
|
|
1436
|
-
|
|
1437
|
-
(`args`) => `Promise`\<`boolean`\>
|
|
1438
|
-
|
|
1439
|
-
Verify that a message was signed by the provided address.
|
|
1440
|
-
|
|
1441
|
-
Compatible with Smart Contract Accounts & Externally Owned Accounts via [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492).
|
|
1442
|
-
|
|
1443
|
-
- Docs [https://viem.sh/docs/actions/public/verifyMessage](https://viem.sh/docs/actions/public/verifyMessage)
|
|
1444
|
-
|
|
1445
|
-
##### verifySiweMessage
|
|
1446
|
-
|
|
1447
|
-
(`args`) => `Promise`\<`boolean`\>
|
|
1448
|
-
|
|
1449
|
-
Verifies [EIP-4361](https://eips.ethereum.org/EIPS/eip-4361) formatted message was signed.
|
|
1450
|
-
|
|
1451
|
-
Compatible with Smart Contract Accounts & Externally Owned Accounts via [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492).
|
|
1452
|
-
|
|
1453
|
-
- Docs [https://viem.sh/docs/siwe/actions/verifySiweMessage](https://viem.sh/docs/siwe/actions/verifySiweMessage)
|
|
1454
|
-
|
|
1455
|
-
##### verifyTypedData
|
|
1456
|
-
|
|
1457
|
-
(`args`) => `Promise`\<`boolean`\>
|
|
1458
|
-
|
|
1459
|
-
Verify that typed data was signed by the provided address.
|
|
1460
|
-
|
|
1461
|
-
- Docs [https://viem.sh/docs/actions/public/verifyTypedData](https://viem.sh/docs/actions/public/verifyTypedData)
|
|
1462
|
-
|
|
1463
|
-
##### waitForTransactionReceipt
|
|
1464
|
-
|
|
1465
|
-
(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>
|
|
1466
|
-
|
|
1467
|
-
Waits for the [Transaction](https://viem.sh/docs/glossary/terms#transaction) to be included on a [Block](https://viem.sh/docs/glossary/terms#block) (one confirmation), and then returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt). If the Transaction reverts, then the action will throw an error.
|
|
1468
|
-
|
|
1469
|
-
- Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt
|
|
1470
|
-
- Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions
|
|
1471
|
-
- JSON-RPC Methods:
|
|
1472
|
-
- Polls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt) on each block until it has been processed.
|
|
1473
|
-
- If a Transaction has been replaced:
|
|
1474
|
-
- Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) and extracts the transactions
|
|
1475
|
-
- Checks if one of the Transactions is a replacement
|
|
1476
|
-
- If so, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).
|
|
1477
|
-
|
|
1478
|
-
**Remarks**
|
|
1479
|
-
|
|
1480
|
-
The `waitForTransactionReceipt` action additionally supports Replacement detection (e.g. sped up Transactions).
|
|
1481
|
-
|
|
1482
|
-
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.
|
|
1483
|
-
|
|
1484
|
-
There are 3 types of Transaction Replacement reasons:
|
|
1485
|
-
|
|
1486
|
-
- `repriced`: The gas price has been modified (e.g. different `maxFeePerGas`)
|
|
1487
|
-
- `cancelled`: The Transaction has been cancelled (e.g. `value === 0n`)
|
|
1488
|
-
- `replaced`: The Transaction has been replaced (e.g. different `value` or `data`)
|
|
1489
|
-
|
|
1490
|
-
**Example**
|
|
1491
|
-
|
|
1492
|
-
```ts
|
|
1493
|
-
import { createPublicClient, http } from 'viem'
|
|
1494
|
-
import { mainnet } from 'viem/chains'
|
|
1495
|
-
|
|
1496
|
-
const client = createPublicClient({
|
|
1497
|
-
chain: mainnet,
|
|
1498
|
-
transport: http(),
|
|
1499
|
-
})
|
|
1500
|
-
const transactionReceipt = await client.waitForTransactionReceipt({
|
|
1501
|
-
hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
1502
|
-
})
|
|
1503
|
-
```
|
|
1504
|
-
|
|
1505
|
-
##### watchBlockNumber
|
|
1506
|
-
|
|
1507
|
-
(`args`) => [`WatchBlockNumberReturnType`](https://viem.sh/docs/index.html)
|
|
1508
|
-
|
|
1509
|
-
Watches and returns incoming block numbers.
|
|
1510
|
-
|
|
1511
|
-
- Docs: https://viem.sh/docs/actions/public/watchBlockNumber
|
|
1512
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks
|
|
1513
|
-
- JSON-RPC Methods:
|
|
1514
|
-
- When `poll: true`, calls [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber) on a polling interval.
|
|
1515
|
-
- When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `"newHeads"` event.
|
|
1516
|
-
|
|
1517
|
-
**Example**
|
|
1518
|
-
|
|
1519
|
-
```ts
|
|
1520
|
-
import { createPublicClient, http } from 'viem'
|
|
1521
|
-
import { mainnet } from 'viem/chains'
|
|
1522
|
-
|
|
1523
|
-
const client = createPublicClient({
|
|
1524
|
-
chain: mainnet,
|
|
1525
|
-
transport: http(),
|
|
1526
|
-
})
|
|
1527
|
-
const unwatch = await client.watchBlockNumber({
|
|
1528
|
-
onBlockNumber: (blockNumber) => console.log(blockNumber),
|
|
1529
|
-
})
|
|
1530
|
-
```
|
|
1531
|
-
|
|
1532
|
-
##### watchBlocks
|
|
1533
|
-
|
|
1534
|
-
\<`includeTransactions`, `blockTag`\>(`args`) => [`WatchBlocksReturnType`](https://viem.sh/docs/index.html)
|
|
1535
|
-
|
|
1536
|
-
Watches and returns information for incoming blocks.
|
|
1537
|
-
|
|
1538
|
-
- Docs: https://viem.sh/docs/actions/public/watchBlocks
|
|
1539
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks
|
|
1540
|
-
- JSON-RPC Methods:
|
|
1541
|
-
- When `poll: true`, calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getBlockByNumber) on a polling interval.
|
|
1542
|
-
- When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `"newHeads"` event.
|
|
1543
|
-
|
|
1544
|
-
**Example**
|
|
1545
|
-
|
|
1546
|
-
```ts
|
|
1547
|
-
import { createPublicClient, http } from 'viem'
|
|
1548
|
-
import { mainnet } from 'viem/chains'
|
|
1549
|
-
|
|
1550
|
-
const client = createPublicClient({
|
|
1551
|
-
chain: mainnet,
|
|
1552
|
-
transport: http(),
|
|
1553
|
-
})
|
|
1554
|
-
const unwatch = await client.watchBlocks({
|
|
1555
|
-
onBlock: (block) => console.log(block),
|
|
1556
|
-
})
|
|
1557
|
-
```
|
|
1558
|
-
|
|
1559
|
-
##### watchContractEvent
|
|
1560
|
-
|
|
1561
|
-
\<`abi`, `eventName`, `strict`\>(`args`) => [`WatchContractEventReturnType`](https://viem.sh/docs/index.html)
|
|
1562
|
-
|
|
1563
|
-
Watches and returns emitted contract event logs.
|
|
1564
|
-
|
|
1565
|
-
- Docs: https://viem.sh/docs/contract/watchContractEvent
|
|
1566
|
-
|
|
1567
|
-
**Remarks**
|
|
1568
|
-
|
|
1569
|
-
This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).
|
|
1570
|
-
|
|
1571
|
-
`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.
|
|
1572
|
-
|
|
1573
|
-
**Example**
|
|
1574
|
-
|
|
1575
|
-
```ts
|
|
1576
|
-
import { createPublicClient, http, parseAbi } from 'viem'
|
|
1577
|
-
import { mainnet } from 'viem/chains'
|
|
1578
|
-
|
|
1579
|
-
const client = createPublicClient({
|
|
1580
|
-
chain: mainnet,
|
|
1581
|
-
transport: http(),
|
|
1582
|
-
})
|
|
1583
|
-
const unwatch = client.watchContractEvent({
|
|
1584
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
1585
|
-
abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),
|
|
1586
|
-
eventName: 'Transfer',
|
|
1587
|
-
args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },
|
|
1588
|
-
onLogs: (logs) => console.log(logs),
|
|
1589
|
-
})
|
|
1590
|
-
```
|
|
1591
|
-
|
|
1592
|
-
##### watchEvent
|
|
1593
|
-
|
|
1594
|
-
\<`abiEvent`, `abiEvents`, `strict`\>(`args`) => [`WatchEventReturnType`](https://viem.sh/docs/index.html)
|
|
1595
|
-
|
|
1596
|
-
Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms#event-log).
|
|
1597
|
-
|
|
1598
|
-
- Docs: https://viem.sh/docs/actions/public/watchEvent
|
|
1599
|
-
- JSON-RPC Methods:
|
|
1600
|
-
- **RPC Provider supports `eth_newFilter`:**
|
|
1601
|
-
- Calls [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter) to create a filter (called on initialize).
|
|
1602
|
-
- On a polling interval, it will call [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges).
|
|
1603
|
-
- **RPC Provider does not support `eth_newFilter`:**
|
|
1604
|
-
- Calls [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs) for each block between the polling interval.
|
|
1605
|
-
|
|
1606
|
-
**Remarks**
|
|
1607
|
-
|
|
1608
|
-
This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent#onLogs).
|
|
1609
|
-
|
|
1610
|
-
`watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) 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.
|
|
1611
|
-
|
|
1612
|
-
**Example**
|
|
1613
|
-
|
|
1614
|
-
```ts
|
|
1615
|
-
import { createPublicClient, http } from 'viem'
|
|
1616
|
-
import { mainnet } from 'viem/chains'
|
|
1617
|
-
|
|
1618
|
-
const client = createPublicClient({
|
|
1619
|
-
chain: mainnet,
|
|
1620
|
-
transport: http(),
|
|
1621
|
-
})
|
|
1622
|
-
const unwatch = client.watchEvent({
|
|
1623
|
-
onLogs: (logs) => console.log(logs),
|
|
1624
|
-
})
|
|
1625
|
-
```
|
|
1626
|
-
|
|
1627
|
-
##### watchPendingTransactions
|
|
1628
|
-
|
|
1629
|
-
(`args`) => [`WatchPendingTransactionsReturnType`](https://viem.sh/docs/index.html)
|
|
1630
|
-
|
|
1631
|
-
Watches and returns pending transaction hashes.
|
|
1632
|
-
|
|
1633
|
-
- Docs: https://viem.sh/docs/actions/public/watchPendingTransactions
|
|
1634
|
-
- JSON-RPC Methods:
|
|
1635
|
-
- When `poll: true`
|
|
1636
|
-
- Calls [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter) to initialize the filter.
|
|
1637
|
-
- Calls [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getFilterChanges) on a polling interval.
|
|
1638
|
-
- When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `"newPendingTransactions"` event.
|
|
1639
|
-
|
|
1640
|
-
**Remarks**
|
|
1641
|
-
|
|
1642
|
-
This Action will batch up all the pending transactions found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchPendingTransactions#pollinginterval-optional), and invoke them via [`onTransactions`](https://viem.sh/docs/actions/public/watchPendingTransactions#ontransactions).
|
|
1643
|
-
|
|
1644
|
-
**Example**
|
|
1645
|
-
|
|
1646
|
-
```ts
|
|
1647
|
-
import { createPublicClient, http } from 'viem'
|
|
1648
|
-
import { mainnet } from 'viem/chains'
|
|
1649
|
-
|
|
1650
|
-
const client = createPublicClient({
|
|
1651
|
-
chain: mainnet,
|
|
1652
|
-
transport: http(),
|
|
1653
|
-
})
|
|
1654
|
-
const unwatch = await client.watchPendingTransactions({
|
|
1655
|
-
onTransactions: (hashes) => console.log(hashes),
|
|
1656
|
-
})
|
|
1657
|
-
```
|
|
1658
|
-
|
|
1659
|
-
|
|
|
1660
|
-
|
|
1661
|
-
\{ `account`: [`Account`](https://viem.sh/docs/index.html) \| `undefined`; `addChain`: (`args`) => `Promise`\<`void`\>; `batch?`: \{ `multicall?`: `boolean` \| \{ `batchSize?`: `number`; `deployless?`: `boolean`; `wait?`: `number`; \}; \}; `cacheTime`: `number`; `ccipRead?`: `false` \| \{ `request?`: (`parameters`) => `Promise`\<`` `0x${string}` ``\>; \}; `chain`: [`Chain`](https://viem.sh/docs/index.html) \| `undefined`; `deployContract`: \<`abi`, `chainOverride`\>(`args`) => `Promise`\<`` `0x${string}` ``\>; `experimental_blockTag?`: [`BlockTag`](https://viem.sh/docs/index.html); `extend`: \<`client`\>(`fn`) => [`Client`](https://viem.sh/docs/index.html)\<[`Transport`](https://viem.sh/docs/index.html), [`Chain`](https://viem.sh/docs/index.html) \| `undefined`, [`Account`](https://viem.sh/docs/index.html) \| `undefined`, [`WalletRpcSchema`](https://viem.sh/docs/index.html), \{ \[K in string \| number \| symbol\]: client\[K\] \} & [`WalletActions`](https://viem.sh/docs/index.html)\<[`Chain`](https://viem.sh/docs/index.html) \| `undefined`, [`Account`](https://viem.sh/docs/index.html) \| `undefined`\>\>; `fillTransaction`: \<`chainOverride`, `accountOverride`\>(`args`) => `Promise`\<[`FillTransactionReturnType`](https://viem.sh/docs/index.html)\<[`Chain`](https://viem.sh/docs/index.html) \| `undefined`, `chainOverride`\>\>; `getAddresses`: () => `Promise`\<[`GetAddressesReturnType`](https://viem.sh/docs/index.html)\>; `getCallsStatus`: (`parameters`) => `Promise`\<\{ `atomic`: `boolean`; `capabilities?`: \{\[`key`: `string`\]: `any`; \} \| \{\[`key`: `string`\]: `any`; \}; `chainId`: `number`; `id`: `string`; `receipts?`: [`WalletCallReceipt`](https://viem.sh/docs/index.html)\<`bigint`, `"success"` \| `"reverted"`\>[]; `status`: `"pending"` \| `"success"` \| `"failure"` \| `undefined`; `statusCode`: `number`; `version`: `string`; \}\>; `getCapabilities`: \<`chainId`\>(`parameters?`) => `Promise`\<\{ \[K in string \| number \| symbol\]: (chainId extends number ? \{ atomic?: \{ status: ... \}; paymasterService?: \{ supported: ... \}; unstable\_addSubAccount?: \{ keyTypes: ...; supported: ... \}; \[key: string\]: any \} : ChainIdToCapabilities\<Capabilities\<\{ atomic?: ...; paymasterService?: ...; unstable\_addSubAccount?: ...; \[key: ...\]: ... \}\>, number\>)\[K\] \}\>; `getChainId`: () => `Promise`\<`number`\>; `getPermissions`: () => `Promise`\<[`GetPermissionsReturnType`](https://viem.sh/docs/index.html)\>; `key`: `string`; `name`: `string`; `pollingInterval`: `number`; `prepareAuthorization`: (`parameters`) => `Promise`\<[`PrepareAuthorizationReturnType`](https://viem.sh/docs/index.html)\>; `prepareTransactionRequest`: \<`request`, `chainOverride`, `accountOverride`\>(`args`) => `Promise`\<\{ \[K in string \| number \| symbol\]: (UnionRequiredBy\<Extract\<(...), (...)\> & \{ chainId?: ... \}, ParameterTypeToParameters\<(...) extends (...) ? (...) : (...)\>\> & (unknown extends request\["kzg"\] ? \{\} : Pick\<request, "kzg"\>))\[K\] \}\>; `request`: [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<[`WalletRpcSchema`](https://viem.sh/docs/index.html)\>; `requestAddresses`: () => `Promise`\<[`RequestAddressesReturnType`](https://viem.sh/docs/index.html)\>; `requestPermissions`: (`args`) => `Promise`\<[`RequestPermissionsReturnType`](https://viem.sh/docs/index.html)\>; `sendCalls`: \<`calls`, `chainOverride`\>(`parameters`) => `Promise`\<\{ `capabilities?`: \{\[`key`: `string`\]: `any`; \}; `id`: `string`; \}\>; `sendCallsSync`: \<`calls`, `chainOverride`\>(`parameters`) => `Promise`\<\{ `atomic`: `boolean`; `capabilities?`: \{\[`key`: `string`\]: `any`; \} \| \{\[`key`: `string`\]: `any`; \}; `chainId`: `number`; `id`: `string`; `receipts?`: [`WalletCallReceipt`](https://viem.sh/docs/index.html)\<`bigint`, `"success"` \| `"reverted"`\>[]; `status`: `"pending"` \| `"success"` \| `"failure"` \| `undefined`; `statusCode`: `number`; `version`: `string`; \}\>; `sendRawTransaction`: (`args`) => `Promise`\<`` `0x${string}` ``\>; `sendRawTransactionSync`: (`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>; `sendTransaction`: \<`request`, `chainOverride`\>(`args`) => `Promise`\<`` `0x${string}` ``\>; `sendTransactionSync`: \<`request`, `chainOverride`\>(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>; `showCallsStatus`: (`parameters`) => `Promise`\<`void`\>; `signAuthorization`: (`parameters`) => `Promise`\<[`SignAuthorizationReturnType`](https://viem.sh/docs/index.html)\>; `signMessage`: (`args`) => `Promise`\<`` `0x${string}` ``\>; `signTransaction`: \<`chainOverride`, `request`\>(`args`) => `Promise`\<[`TransactionSerialized`](https://viem.sh/docs/index.html)\<[`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, `request` *extends* [`LegacyProperties`](https://viem.sh/docs/index.html) ? `"legacy"` : `never` \| `request` *extends* [`EIP1559Properties`](https://viem.sh/docs/index.html) ? `"eip1559"` : `never` \| `request` *extends* [`EIP2930Properties`](https://viem.sh/docs/index.html) ? `"eip2930"` : `never` \| `request` *extends* [`EIP4844Properties`](https://viem.sh/docs/index.html) ? `"eip4844"` : `never` \| `request` *extends* [`EIP7702Properties`](https://viem.sh/docs/index.html) ? `"eip7702"` : `never` \| `request`\[`"type"`\] *extends* `string` \| `undefined` ? `Extract`\<`any`\[`any`\], `string`\> : `never`\>, [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip1559"` ? `` `0x02${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip2930"` ? `` `0x01${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip4844"` ? `` `0x03${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip7702"` ? `` `0x04${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"legacy"` ? [`TransactionSerializedLegacy`](https://viem.sh/docs/index.html) : `never`\>\>; `signTypedData`: \<`typedData`, `primaryType`\>(`args`) => `Promise`\<`` `0x${string}` ``\>; `switchChain`: (`args`) => `Promise`\<`void`\>; `transport`: [`TransportConfig`](https://viem.sh/docs/index.html)\<`string`, [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\> & `Record`\<`string`, `any`\>; `type`: `string`; `uid`: `string`; `waitForCallsStatus`: (`parameters`) => `Promise`\<\{ `atomic`: `boolean`; `capabilities?`: \{\[`key`: `string`\]: `any`; \} \| \{\[`key`: `string`\]: `any`; \}; `chainId`: `number`; `id`: `string`; `receipts?`: [`WalletCallReceipt`](https://viem.sh/docs/index.html)\<`bigint`, `"success"` \| `"reverted"`\>[]; `status`: `"pending"` \| `"success"` \| `"failure"` \| `undefined`; `statusCode`: `number`; `version`: `string`; \}\>; `watchAsset`: (`args`) => `Promise`\<`boolean`\>; `writeContract`: \<`abi`, `functionName`, `args`, `chainOverride`\>(`args`) => `Promise`\<`` `0x${string}` ``\>; `writeContractSync`: \<`abi`, `functionName`, `args`, `chainOverride`\>(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>; \}
|
|
1662
|
-
|
|
1663
|
-
##### account
|
|
1664
|
-
|
|
1665
|
-
[`Account`](https://viem.sh/docs/index.html) \| `undefined`
|
|
1666
|
-
|
|
1667
|
-
The Account of the Client.
|
|
1668
|
-
|
|
1669
|
-
##### addChain
|
|
1670
|
-
|
|
1671
|
-
(`args`) => `Promise`\<`void`\>
|
|
1672
|
-
|
|
1673
|
-
Adds an EVM chain to the wallet.
|
|
1674
|
-
|
|
1675
|
-
- Docs: https://viem.sh/docs/actions/wallet/addChain
|
|
1676
|
-
- JSON-RPC Methods: [`eth_addEthereumChain`](https://eips.ethereum.org/EIPS/eip-3085)
|
|
1677
|
-
|
|
1678
|
-
**Example**
|
|
1679
|
-
|
|
1680
|
-
```ts
|
|
1681
|
-
import { createWalletClient, custom } from 'viem'
|
|
1682
|
-
import { optimism } from 'viem/chains'
|
|
1683
|
-
|
|
1684
|
-
const client = createWalletClient({
|
|
1685
|
-
transport: custom(window.ethereum),
|
|
1686
|
-
})
|
|
1687
|
-
await client.addChain({ chain: optimism })
|
|
1688
|
-
```
|
|
1689
|
-
|
|
1690
|
-
##### batch?
|
|
1691
|
-
|
|
1692
|
-
\{ `multicall?`: `boolean` \| \{ `batchSize?`: `number`; `deployless?`: `boolean`; `wait?`: `number`; \}; \}
|
|
1693
|
-
|
|
1694
|
-
Flags for batch settings.
|
|
1695
|
-
|
|
1696
|
-
##### batch.multicall?
|
|
1697
|
-
|
|
1698
|
-
`boolean` \| \{ `batchSize?`: `number`; `deployless?`: `boolean`; `wait?`: `number`; \}
|
|
1699
|
-
|
|
1700
|
-
Toggle to enable `eth_call` multicall aggregation.
|
|
1701
|
-
|
|
1702
|
-
##### cacheTime
|
|
1703
|
-
|
|
1704
|
-
`number`
|
|
1705
|
-
|
|
1706
|
-
Time (in ms) that cached data will remain in memory.
|
|
1707
|
-
|
|
1708
|
-
##### ccipRead?
|
|
1709
|
-
|
|
1710
|
-
`false` \| \{ `request?`: (`parameters`) => `Promise`\<`` `0x${string}` ``\>; \}
|
|
1711
|
-
|
|
1712
|
-
[CCIP Read](https://eips.ethereum.org/EIPS/eip-3668) configuration.
|
|
1713
|
-
|
|
1714
|
-
##### chain
|
|
1715
|
-
|
|
1716
|
-
[`Chain`](https://viem.sh/docs/index.html) \| `undefined`
|
|
1717
|
-
|
|
1718
|
-
Chain for the client.
|
|
1719
|
-
|
|
1720
|
-
##### deployContract
|
|
1721
|
-
|
|
1722
|
-
\<`abi`, `chainOverride`\>(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
1723
|
-
|
|
1724
|
-
Deploys a contract to the network, given bytecode and constructor arguments.
|
|
1725
|
-
|
|
1726
|
-
- Docs: https://viem.sh/docs/contract/deployContract
|
|
1727
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts
|
|
1728
|
-
|
|
1729
|
-
**Example**
|
|
1730
|
-
|
|
1731
|
-
```ts
|
|
1732
|
-
import { createWalletClient, http } from 'viem'
|
|
1733
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
1734
|
-
import { mainnet } from 'viem/chains'
|
|
1735
|
-
|
|
1736
|
-
const client = createWalletClient({
|
|
1737
|
-
account: privateKeyToAccount('0x…'),
|
|
1738
|
-
chain: mainnet,
|
|
1739
|
-
transport: http(),
|
|
1740
|
-
})
|
|
1741
|
-
const hash = await client.deployContract({
|
|
1742
|
-
abi: [],
|
|
1743
|
-
account: '0x…,
|
|
1744
|
-
bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',
|
|
1745
|
-
})
|
|
1746
|
-
```
|
|
1747
|
-
|
|
1748
|
-
##### experimental_blockTag?
|
|
1749
|
-
|
|
1750
|
-
[`BlockTag`](https://viem.sh/docs/index.html)
|
|
1751
|
-
|
|
1752
|
-
Default block tag to use for RPC requests.
|
|
1753
|
-
|
|
1754
|
-
##### extend
|
|
1755
|
-
|
|
1756
|
-
\<`client`\>(`fn`) => [`Client`](https://viem.sh/docs/index.html)\<[`Transport`](https://viem.sh/docs/index.html), [`Chain`](https://viem.sh/docs/index.html) \| `undefined`, [`Account`](https://viem.sh/docs/index.html) \| `undefined`, [`WalletRpcSchema`](https://viem.sh/docs/index.html), \{ \[K in string \| number \| symbol\]: client\[K\] \} & [`WalletActions`](https://viem.sh/docs/index.html)\<[`Chain`](https://viem.sh/docs/index.html) \| `undefined`, [`Account`](https://viem.sh/docs/index.html) \| `undefined`\>\>
|
|
1757
|
-
|
|
1758
|
-
##### fillTransaction
|
|
1759
|
-
|
|
1760
|
-
\<`chainOverride`, `accountOverride`\>(`args`) => `Promise`\<[`FillTransactionReturnType`](https://viem.sh/docs/index.html)\<[`Chain`](https://viem.sh/docs/index.html) \| `undefined`, `chainOverride`\>\>
|
|
1761
|
-
|
|
1762
|
-
Fills a transaction request with the necessary fields to be signed over.
|
|
1763
|
-
|
|
1764
|
-
- Docs: https://viem.sh/docs/actions/public/fillTransaction
|
|
1765
|
-
|
|
1766
|
-
**Example**
|
|
1767
|
-
|
|
1768
|
-
```ts
|
|
1769
|
-
import { createWalletClient, custom } from 'viem'
|
|
1770
|
-
import { mainnet } from 'viem/chains'
|
|
1771
|
-
|
|
1772
|
-
const client = createWalletClient({
|
|
1773
|
-
chain: mainnet,
|
|
1774
|
-
transport: custom(window.ethereum),
|
|
1775
|
-
})
|
|
1776
|
-
const result = await client.fillTransaction({
|
|
1777
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1778
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
1779
|
-
value: parseEther('1'),
|
|
1780
|
-
})
|
|
1781
|
-
```
|
|
1782
|
-
|
|
1783
|
-
##### getAddresses
|
|
1784
|
-
|
|
1785
|
-
() => `Promise`\<[`GetAddressesReturnType`](https://viem.sh/docs/index.html)\>
|
|
1786
|
-
|
|
1787
|
-
Returns a list of account addresses owned by the wallet or client.
|
|
1788
|
-
|
|
1789
|
-
- Docs: https://viem.sh/docs/actions/wallet/getAddresses
|
|
1790
|
-
- JSON-RPC Methods: [`eth_accounts`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_accounts)
|
|
1791
|
-
|
|
1792
|
-
**Example**
|
|
1793
|
-
|
|
1794
|
-
```ts
|
|
1795
|
-
import { createWalletClient, custom } from 'viem'
|
|
1796
|
-
import { mainnet } from 'viem/chains'
|
|
1797
|
-
|
|
1798
|
-
const client = createWalletClient({
|
|
1799
|
-
chain: mainnet,
|
|
1800
|
-
transport: custom(window.ethereum),
|
|
1801
|
-
})
|
|
1802
|
-
const accounts = await client.getAddresses()
|
|
1803
|
-
```
|
|
1804
|
-
|
|
1805
|
-
##### getCallsStatus
|
|
1806
|
-
|
|
1807
|
-
(`parameters`) => `Promise`\<\{ `atomic`: `boolean`; `capabilities?`: \{\[`key`: `string`\]: `any`; \} \| \{\[`key`: `string`\]: `any`; \}; `chainId`: `number`; `id`: `string`; `receipts?`: [`WalletCallReceipt`](https://viem.sh/docs/index.html)\<`bigint`, `"success"` \| `"reverted"`\>[]; `status`: `"pending"` \| `"success"` \| `"failure"` \| `undefined`; `statusCode`: `number`; `version`: `string`; \}\>
|
|
1808
|
-
|
|
1809
|
-
Returns the status of a call batch that was sent via `sendCalls`.
|
|
1810
|
-
|
|
1811
|
-
- Docs: https://viem.sh/docs/actions/wallet/getCallsStatus
|
|
1812
|
-
- JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
|
1813
|
-
|
|
1814
|
-
**Example**
|
|
1815
|
-
|
|
1816
|
-
```ts
|
|
1817
|
-
import { createWalletClient, custom } from 'viem'
|
|
1818
|
-
import { mainnet } from 'viem/chains'
|
|
1819
|
-
|
|
1820
|
-
const client = createWalletClient({
|
|
1821
|
-
chain: mainnet,
|
|
1822
|
-
transport: custom(window.ethereum),
|
|
1823
|
-
})
|
|
1824
|
-
|
|
1825
|
-
const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
|
|
1826
|
-
```
|
|
1827
|
-
|
|
1828
|
-
##### getCapabilities
|
|
1829
|
-
|
|
1830
|
-
\<`chainId`\>(`parameters?`) => `Promise`\<\{ \[K in string \| number \| symbol\]: (chainId extends number ? \{ atomic?: \{ status: ... \}; paymasterService?: \{ supported: ... \}; unstable\_addSubAccount?: \{ keyTypes: ...; supported: ... \}; \[key: string\]: any \} : ChainIdToCapabilities\<Capabilities\<\{ atomic?: ...; paymasterService?: ...; unstable\_addSubAccount?: ...; \[key: ...\]: ... \}\>, number\>)\[K\] \}\>
|
|
1831
|
-
|
|
1832
|
-
Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc).
|
|
1833
|
-
|
|
1834
|
-
- Docs: https://viem.sh/docs/actions/wallet/getCapabilities
|
|
1835
|
-
- JSON-RPC Methods: [`wallet_getCapabilities`](https://eips.ethereum.org/EIPS/eip-5792)
|
|
1836
|
-
|
|
1837
|
-
**Example**
|
|
1838
|
-
|
|
1839
|
-
```ts
|
|
1840
|
-
import { createWalletClient, custom } from 'viem'
|
|
1841
|
-
import { mainnet } from 'viem/chains'
|
|
1842
|
-
|
|
1843
|
-
const client = createWalletClient({
|
|
1844
|
-
chain: mainnet,
|
|
1845
|
-
transport: custom(window.ethereum),
|
|
1846
|
-
})
|
|
1847
|
-
|
|
1848
|
-
const capabilities = await client.getCapabilities({
|
|
1849
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1850
|
-
})
|
|
1851
|
-
```
|
|
1852
|
-
|
|
1853
|
-
##### getChainId
|
|
1854
|
-
|
|
1855
|
-
() => `Promise`\<`number`\>
|
|
1856
|
-
|
|
1857
|
-
Returns the chain ID associated with the current network.
|
|
1858
|
-
|
|
1859
|
-
- Docs: https://viem.sh/docs/actions/public/getChainId
|
|
1860
|
-
- JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)
|
|
1861
|
-
|
|
1862
|
-
**Example**
|
|
1863
|
-
|
|
1864
|
-
```ts
|
|
1865
|
-
import { createWalletClient, http } from 'viem'
|
|
1866
|
-
import { mainnet } from 'viem/chains'
|
|
1867
|
-
|
|
1868
|
-
const client = createWalletClient({
|
|
1869
|
-
chain: mainnet,
|
|
1870
|
-
transport: custom(window.ethereum),
|
|
1871
|
-
})
|
|
1872
|
-
const chainId = await client.getChainId()
|
|
1873
|
-
// 1
|
|
1874
|
-
```
|
|
1875
|
-
|
|
1876
|
-
##### getPermissions
|
|
1877
|
-
|
|
1878
|
-
() => `Promise`\<[`GetPermissionsReturnType`](https://viem.sh/docs/index.html)\>
|
|
1879
|
-
|
|
1880
|
-
Gets the wallets current permissions.
|
|
1881
|
-
|
|
1882
|
-
- Docs: https://viem.sh/docs/actions/wallet/getPermissions
|
|
1883
|
-
- JSON-RPC Methods: [`wallet_getPermissions`](https://eips.ethereum.org/EIPS/eip-2255)
|
|
1884
|
-
|
|
1885
|
-
**Example**
|
|
1886
|
-
|
|
1887
|
-
```ts
|
|
1888
|
-
import { createWalletClient, custom } from 'viem'
|
|
1889
|
-
import { mainnet } from 'viem/chains'
|
|
1890
|
-
|
|
1891
|
-
const client = createWalletClient({
|
|
1892
|
-
chain: mainnet,
|
|
1893
|
-
transport: custom(window.ethereum),
|
|
1894
|
-
})
|
|
1895
|
-
const permissions = await client.getPermissions()
|
|
1896
|
-
```
|
|
1897
|
-
|
|
1898
|
-
##### key
|
|
1899
|
-
|
|
1900
|
-
`string`
|
|
1901
|
-
|
|
1902
|
-
A key for the client.
|
|
1903
|
-
|
|
1904
|
-
##### name
|
|
1905
|
-
|
|
1906
|
-
`string`
|
|
1907
|
-
|
|
1908
|
-
A name for the client.
|
|
1909
|
-
|
|
1910
|
-
##### pollingInterval
|
|
1911
|
-
|
|
1912
|
-
`number`
|
|
1913
|
-
|
|
1914
|
-
Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
|
|
1915
|
-
|
|
1916
|
-
##### prepareAuthorization
|
|
1917
|
-
|
|
1918
|
-
(`parameters`) => `Promise`\<[`PrepareAuthorizationReturnType`](https://viem.sh/docs/index.html)\>
|
|
1919
|
-
|
|
1920
|
-
Prepares an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object for signing.
|
|
1921
|
-
This Action will fill the required fields of the Authorization object if they are not provided (e.g. `nonce` and `chainId`).
|
|
1922
|
-
|
|
1923
|
-
With the prepared Authorization object, you can use [`signAuthorization`](https://viem.sh/docs/eip7702/signAuthorization) to sign over the Authorization object.
|
|
1924
|
-
|
|
1925
|
-
**Examples**
|
|
1926
|
-
|
|
1927
|
-
```ts
|
|
1928
|
-
import { createWalletClient, http } from 'viem'
|
|
1929
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
1930
|
-
import { mainnet } from 'viem/chains'
|
|
1931
|
-
|
|
1932
|
-
const client = createWalletClient({
|
|
1933
|
-
chain: mainnet,
|
|
1934
|
-
transport: http(),
|
|
1935
|
-
})
|
|
1936
|
-
|
|
1937
|
-
const authorization = await client.prepareAuthorization({
|
|
1938
|
-
account: privateKeyToAccount('0x..'),
|
|
1939
|
-
contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1940
|
-
})
|
|
1941
|
-
```
|
|
1942
|
-
|
|
1943
|
-
```ts
|
|
1944
|
-
// Account Hoisting
|
|
1945
|
-
import { createWalletClient, http } from 'viem'
|
|
1946
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
1947
|
-
import { mainnet } from 'viem/chains'
|
|
1948
|
-
|
|
1949
|
-
const client = createWalletClient({
|
|
1950
|
-
account: privateKeyToAccount('0x…'),
|
|
1951
|
-
chain: mainnet,
|
|
1952
|
-
transport: http(),
|
|
1953
|
-
})
|
|
1954
|
-
|
|
1955
|
-
const authorization = await client.prepareAuthorization({
|
|
1956
|
-
contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1957
|
-
})
|
|
1958
|
-
```
|
|
1959
|
-
|
|
1960
|
-
##### prepareTransactionRequest
|
|
1961
|
-
|
|
1962
|
-
\<`request`, `chainOverride`, `accountOverride`\>(`args`) => `Promise`\<\{ \[K in string \| number \| symbol\]: (UnionRequiredBy\<Extract\<(...), (...)\> & \{ chainId?: ... \}, ParameterTypeToParameters\<(...) extends (...) ? (...) : (...)\>\> & (unknown extends request\["kzg"\] ? \{\} : Pick\<request, "kzg"\>))\[K\] \}\>
|
|
1963
|
-
|
|
1964
|
-
Prepares a transaction request for signing.
|
|
1965
|
-
|
|
1966
|
-
- Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest
|
|
1967
|
-
|
|
1968
|
-
**Examples**
|
|
1969
|
-
|
|
1970
|
-
```ts
|
|
1971
|
-
import { createWalletClient, custom } from 'viem'
|
|
1972
|
-
import { mainnet } from 'viem/chains'
|
|
1973
|
-
|
|
1974
|
-
const client = createWalletClient({
|
|
1975
|
-
chain: mainnet,
|
|
1976
|
-
transport: custom(window.ethereum),
|
|
1977
|
-
})
|
|
1978
|
-
const request = await client.prepareTransactionRequest({
|
|
1979
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
1980
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
1981
|
-
value: 1n,
|
|
1982
|
-
})
|
|
1983
|
-
```
|
|
1984
|
-
|
|
1985
|
-
```ts
|
|
1986
|
-
// Account Hoisting
|
|
1987
|
-
import { createWalletClient, http } from 'viem'
|
|
1988
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
1989
|
-
import { mainnet } from 'viem/chains'
|
|
1990
|
-
|
|
1991
|
-
const client = createWalletClient({
|
|
1992
|
-
account: privateKeyToAccount('0x…'),
|
|
1993
|
-
chain: mainnet,
|
|
1994
|
-
transport: custom(window.ethereum),
|
|
1995
|
-
})
|
|
1996
|
-
const request = await client.prepareTransactionRequest({
|
|
1997
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
1998
|
-
value: 1n,
|
|
1999
|
-
})
|
|
2000
|
-
```
|
|
2001
|
-
|
|
2002
|
-
##### request
|
|
2003
|
-
|
|
2004
|
-
[`EIP1193RequestFn`](https://viem.sh/docs/index.html)\<[`WalletRpcSchema`](https://viem.sh/docs/index.html)\>
|
|
2005
|
-
|
|
2006
|
-
Request function wrapped with friendly error handling
|
|
2007
|
-
|
|
2008
|
-
##### requestAddresses
|
|
2009
|
-
|
|
2010
|
-
() => `Promise`\<[`RequestAddressesReturnType`](https://viem.sh/docs/index.html)\>
|
|
2011
|
-
|
|
2012
|
-
Requests a list of accounts managed by a wallet.
|
|
2013
|
-
|
|
2014
|
-
- Docs: https://viem.sh/docs/actions/wallet/requestAddresses
|
|
2015
|
-
- JSON-RPC Methods: [`eth_requestAccounts`](https://eips.ethereum.org/EIPS/eip-1102)
|
|
2016
|
-
|
|
2017
|
-
Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses).
|
|
2018
|
-
|
|
2019
|
-
This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts.
|
|
2020
|
-
|
|
2021
|
-
**Example**
|
|
2022
|
-
|
|
2023
|
-
```ts
|
|
2024
|
-
import { createWalletClient, custom } from 'viem'
|
|
2025
|
-
import { mainnet } from 'viem/chains'
|
|
2026
|
-
|
|
2027
|
-
const client = createWalletClient({
|
|
2028
|
-
chain: mainnet,
|
|
2029
|
-
transport: custom(window.ethereum),
|
|
2030
|
-
})
|
|
2031
|
-
const accounts = await client.requestAddresses()
|
|
2032
|
-
```
|
|
2033
|
-
|
|
2034
|
-
##### requestPermissions
|
|
2035
|
-
|
|
2036
|
-
(`args`) => `Promise`\<[`RequestPermissionsReturnType`](https://viem.sh/docs/index.html)\>
|
|
2037
|
-
|
|
2038
|
-
Requests permissions for a wallet.
|
|
2039
|
-
|
|
2040
|
-
- Docs: https://viem.sh/docs/actions/wallet/requestPermissions
|
|
2041
|
-
- JSON-RPC Methods: [`wallet_requestPermissions`](https://eips.ethereum.org/EIPS/eip-2255)
|
|
2042
|
-
|
|
2043
|
-
**Example**
|
|
2044
|
-
|
|
2045
|
-
```ts
|
|
2046
|
-
import { createWalletClient, custom } from 'viem'
|
|
2047
|
-
import { mainnet } from 'viem/chains'
|
|
2048
|
-
|
|
2049
|
-
const client = createWalletClient({
|
|
2050
|
-
chain: mainnet,
|
|
2051
|
-
transport: custom(window.ethereum),
|
|
2052
|
-
})
|
|
2053
|
-
const permissions = await client.requestPermissions({
|
|
2054
|
-
eth_accounts: {}
|
|
2055
|
-
})
|
|
2056
|
-
```
|
|
2057
|
-
|
|
2058
|
-
##### sendCalls
|
|
2059
|
-
|
|
2060
|
-
\<`calls`, `chainOverride`\>(`parameters`) => `Promise`\<\{ `capabilities?`: \{\[`key`: `string`\]: `any`; \}; `id`: `string`; \}\>
|
|
2061
|
-
|
|
2062
|
-
Requests the connected wallet to send a batch of calls.
|
|
2063
|
-
|
|
2064
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendCalls
|
|
2065
|
-
- JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
|
2066
|
-
|
|
2067
|
-
**Example**
|
|
2068
|
-
|
|
2069
|
-
```ts
|
|
2070
|
-
import { createWalletClient, custom } from 'viem'
|
|
2071
|
-
import { mainnet } from 'viem/chains'
|
|
2072
|
-
|
|
2073
|
-
const client = createWalletClient({
|
|
2074
|
-
chain: mainnet,
|
|
2075
|
-
transport: custom(window.ethereum),
|
|
2076
|
-
})
|
|
2077
|
-
|
|
2078
|
-
const id = await client.sendCalls({
|
|
2079
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2080
|
-
calls: [
|
|
2081
|
-
{
|
|
2082
|
-
data: '0xdeadbeef',
|
|
2083
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2084
|
-
},
|
|
2085
|
-
{
|
|
2086
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2087
|
-
value: 69420n,
|
|
2088
|
-
},
|
|
2089
|
-
],
|
|
2090
|
-
})
|
|
2091
|
-
```
|
|
2092
|
-
|
|
2093
|
-
##### sendCallsSync
|
|
2094
|
-
|
|
2095
|
-
\<`calls`, `chainOverride`\>(`parameters`) => `Promise`\<\{ `atomic`: `boolean`; `capabilities?`: \{\[`key`: `string`\]: `any`; \} \| \{\[`key`: `string`\]: `any`; \}; `chainId`: `number`; `id`: `string`; `receipts?`: [`WalletCallReceipt`](https://viem.sh/docs/index.html)\<`bigint`, `"success"` \| `"reverted"`\>[]; `status`: `"pending"` \| `"success"` \| `"failure"` \| `undefined`; `statusCode`: `number`; `version`: `string`; \}\>
|
|
2096
|
-
|
|
2097
|
-
Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block.
|
|
2098
|
-
|
|
2099
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendCallsSync
|
|
2100
|
-
- JSON-RPC Methods: [`wallet_sendCalls`](https://eips.ethereum.org/EIPS/eip-5792)
|
|
2101
|
-
|
|
2102
|
-
**Example**
|
|
2103
|
-
|
|
2104
|
-
```ts
|
|
2105
|
-
import { createWalletClient, custom } from 'viem'
|
|
2106
|
-
import { mainnet } from 'viem/chains'
|
|
2107
|
-
|
|
2108
|
-
const client = createWalletClient({
|
|
2109
|
-
chain: mainnet,
|
|
2110
|
-
transport: custom(window.ethereum),
|
|
2111
|
-
})
|
|
2112
|
-
|
|
2113
|
-
const status = await client.sendCallsSync({
|
|
2114
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2115
|
-
calls: [
|
|
2116
|
-
{
|
|
2117
|
-
data: '0xdeadbeef',
|
|
2118
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2119
|
-
},
|
|
2120
|
-
{
|
|
2121
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2122
|
-
value: 69420n,
|
|
2123
|
-
},
|
|
2124
|
-
],
|
|
2125
|
-
})
|
|
2126
|
-
```
|
|
2127
|
-
|
|
2128
|
-
##### sendRawTransaction
|
|
2129
|
-
|
|
2130
|
-
(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
2131
|
-
|
|
2132
|
-
Sends a **signed** transaction to the network
|
|
2133
|
-
|
|
2134
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction
|
|
2135
|
-
- JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
|
2136
|
-
|
|
2137
|
-
**Example**
|
|
2138
|
-
|
|
2139
|
-
```ts
|
|
2140
|
-
import { createWalletClient, custom } from 'viem'
|
|
2141
|
-
import { mainnet } from 'viem/chains'
|
|
2142
|
-
import { sendRawTransaction } from 'viem/wallet'
|
|
2143
|
-
|
|
2144
|
-
const client = createWalletClient({
|
|
2145
|
-
chain: mainnet,
|
|
2146
|
-
transport: custom(window.ethereum),
|
|
2147
|
-
})
|
|
2148
|
-
|
|
2149
|
-
const hash = await client.sendRawTransaction({
|
|
2150
|
-
serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
2151
|
-
})
|
|
2152
|
-
```
|
|
2153
|
-
|
|
2154
|
-
##### sendRawTransactionSync
|
|
2155
|
-
|
|
2156
|
-
(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>
|
|
2157
|
-
|
|
2158
|
-
Sends a **signed** transaction to the network synchronously,
|
|
2159
|
-
and waits for the transaction to be included in a block.
|
|
2160
|
-
|
|
2161
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync
|
|
2162
|
-
- JSON-RPC Method: [`eth_sendRawTransactionSync`](https://eips.ethereum.org/EIPS/eip-7966)
|
|
2163
|
-
|
|
2164
|
-
**Example**
|
|
2165
|
-
|
|
2166
|
-
```ts
|
|
2167
|
-
import { createWalletClient, custom } from 'viem'
|
|
2168
|
-
import { mainnet } from 'viem/chains'
|
|
2169
|
-
import { sendRawTransactionSync } from 'viem/wallet'
|
|
2170
|
-
|
|
2171
|
-
const client = createWalletClient({
|
|
2172
|
-
chain: mainnet,
|
|
2173
|
-
transport: custom(window.ethereum),
|
|
2174
|
-
})
|
|
2175
|
-
|
|
2176
|
-
const receipt = await client.sendRawTransactionSync({
|
|
2177
|
-
serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'
|
|
2178
|
-
})
|
|
2179
|
-
```
|
|
2180
|
-
|
|
2181
|
-
##### sendTransaction
|
|
2182
|
-
|
|
2183
|
-
\<`request`, `chainOverride`\>(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
2184
|
-
|
|
2185
|
-
Creates, signs, and sends a new transaction to the network.
|
|
2186
|
-
|
|
2187
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendTransaction
|
|
2188
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions
|
|
2189
|
-
- JSON-RPC Methods:
|
|
2190
|
-
- JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
2191
|
-
- Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
2192
|
-
|
|
2193
|
-
**Examples**
|
|
2194
|
-
|
|
2195
|
-
```ts
|
|
2196
|
-
import { createWalletClient, custom } from 'viem'
|
|
2197
|
-
import { mainnet } from 'viem/chains'
|
|
2198
|
-
|
|
2199
|
-
const client = createWalletClient({
|
|
2200
|
-
chain: mainnet,
|
|
2201
|
-
transport: custom(window.ethereum),
|
|
2202
|
-
})
|
|
2203
|
-
const hash = await client.sendTransaction({
|
|
2204
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2205
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2206
|
-
value: 1000000000000000000n,
|
|
2207
|
-
})
|
|
2208
|
-
```
|
|
2209
|
-
|
|
2210
|
-
```ts
|
|
2211
|
-
// Account Hoisting
|
|
2212
|
-
import { createWalletClient, http } from 'viem'
|
|
2213
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2214
|
-
import { mainnet } from 'viem/chains'
|
|
2215
|
-
|
|
2216
|
-
const client = createWalletClient({
|
|
2217
|
-
account: privateKeyToAccount('0x…'),
|
|
2218
|
-
chain: mainnet,
|
|
2219
|
-
transport: http(),
|
|
2220
|
-
})
|
|
2221
|
-
const hash = await client.sendTransaction({
|
|
2222
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2223
|
-
value: 1000000000000000000n,
|
|
2224
|
-
})
|
|
2225
|
-
```
|
|
2226
|
-
|
|
2227
|
-
##### sendTransactionSync
|
|
2228
|
-
|
|
2229
|
-
\<`request`, `chainOverride`\>(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>
|
|
2230
|
-
|
|
2231
|
-
Creates, signs, and sends a new transaction to the network synchronously.
|
|
2232
|
-
Returns the transaction receipt.
|
|
2233
|
-
|
|
2234
|
-
- Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync
|
|
2235
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions
|
|
2236
|
-
- JSON-RPC Methods:
|
|
2237
|
-
- JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
2238
|
-
- Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
2239
|
-
|
|
2240
|
-
**Examples**
|
|
2241
|
-
|
|
2242
|
-
```ts
|
|
2243
|
-
import { createWalletClient, custom } from 'viem'
|
|
2244
|
-
import { mainnet } from 'viem/chains'
|
|
2245
|
-
|
|
2246
|
-
const client = createWalletClient({
|
|
2247
|
-
chain: mainnet,
|
|
2248
|
-
transport: custom(window.ethereum),
|
|
2249
|
-
})
|
|
2250
|
-
const receipt = await client.sendTransactionSync({
|
|
2251
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2252
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2253
|
-
value: 1000000000000000000n,
|
|
2254
|
-
})
|
|
2255
|
-
```
|
|
2256
|
-
|
|
2257
|
-
```ts
|
|
2258
|
-
// Account Hoisting
|
|
2259
|
-
import { createWalletClient, http } from 'viem'
|
|
2260
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2261
|
-
import { mainnet } from 'viem/chains'
|
|
2262
|
-
|
|
2263
|
-
const client = createWalletClient({
|
|
2264
|
-
account: privateKeyToAccount('0x…'),
|
|
2265
|
-
chain: mainnet,
|
|
2266
|
-
transport: http(),
|
|
2267
|
-
})
|
|
2268
|
-
const receipt = await client.sendTransactionSync({
|
|
2269
|
-
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
2270
|
-
value: 1000000000000000000n,
|
|
2271
|
-
})
|
|
2272
|
-
```
|
|
2273
|
-
|
|
2274
|
-
##### showCallsStatus
|
|
2275
|
-
|
|
2276
|
-
(`parameters`) => `Promise`\<`void`\>
|
|
2277
|
-
|
|
2278
|
-
Requests for the wallet to show information about a call batch
|
|
2279
|
-
that was sent via `sendCalls`.
|
|
2280
|
-
|
|
2281
|
-
- Docs: https://viem.sh/docs/actions/wallet/showCallsStatus
|
|
2282
|
-
- JSON-RPC Methods: [`wallet_showCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
|
2283
|
-
|
|
2284
|
-
**Example**
|
|
2285
|
-
|
|
2286
|
-
```ts
|
|
2287
|
-
import { createWalletClient, custom } from 'viem'
|
|
2288
|
-
import { mainnet } from 'viem/chains'
|
|
2289
|
-
|
|
2290
|
-
const client = createWalletClient({
|
|
2291
|
-
chain: mainnet,
|
|
2292
|
-
transport: custom(window.ethereum),
|
|
2293
|
-
})
|
|
2294
|
-
|
|
2295
|
-
await client.showCallsStatus({ id: '0xdeadbeef' })
|
|
2296
|
-
```
|
|
2297
|
-
|
|
2298
|
-
##### signAuthorization
|
|
2299
|
-
|
|
2300
|
-
(`parameters`) => `Promise`\<[`SignAuthorizationReturnType`](https://viem.sh/docs/index.html)\>
|
|
2301
|
-
|
|
2302
|
-
Signs an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object.
|
|
2303
|
-
|
|
2304
|
-
With the calculated signature, you can:
|
|
2305
|
-
- use [`verifyAuthorization`](https://viem.sh/docs/eip7702/verifyAuthorization) to verify the signed Authorization object,
|
|
2306
|
-
- use [`recoverAuthorizationAddress`](https://viem.sh/docs/eip7702/recoverAuthorizationAddress) to recover the signing address from the signed Authorization object.
|
|
2307
|
-
|
|
2308
|
-
**Examples**
|
|
2309
|
-
|
|
2310
|
-
```ts
|
|
2311
|
-
import { createWalletClient, http } from 'viem'
|
|
2312
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2313
|
-
import { mainnet } from 'viem/chains'
|
|
2314
|
-
|
|
2315
|
-
const client = createWalletClient({
|
|
2316
|
-
chain: mainnet,
|
|
2317
|
-
transport: http(),
|
|
2318
|
-
})
|
|
2319
|
-
|
|
2320
|
-
const signature = await client.signAuthorization({
|
|
2321
|
-
account: privateKeyToAccount('0x..'),
|
|
2322
|
-
contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2323
|
-
})
|
|
2324
|
-
```
|
|
2325
|
-
|
|
2326
|
-
```ts
|
|
2327
|
-
// Account Hoisting
|
|
2328
|
-
import { createWalletClient, http } from 'viem'
|
|
2329
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2330
|
-
import { mainnet } from 'viem/chains'
|
|
2331
|
-
|
|
2332
|
-
const client = createWalletClient({
|
|
2333
|
-
account: privateKeyToAccount('0x…'),
|
|
2334
|
-
chain: mainnet,
|
|
2335
|
-
transport: http(),
|
|
2336
|
-
})
|
|
2337
|
-
|
|
2338
|
-
const signature = await client.signAuthorization({
|
|
2339
|
-
contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2340
|
-
})
|
|
2341
|
-
```
|
|
2342
|
-
|
|
2343
|
-
##### signMessage
|
|
2344
|
-
|
|
2345
|
-
(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
2346
|
-
|
|
2347
|
-
Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
2348
|
-
|
|
2349
|
-
- Docs: https://viem.sh/docs/actions/wallet/signMessage
|
|
2350
|
-
- JSON-RPC Methods:
|
|
2351
|
-
- JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data#personal-sign)
|
|
2352
|
-
- Local Accounts: Signs locally. No JSON-RPC request.
|
|
2353
|
-
|
|
2354
|
-
With the calculated signature, you can:
|
|
2355
|
-
- use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage) to verify the signature,
|
|
2356
|
-
- use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress) to recover the signing address from a signature.
|
|
2357
|
-
|
|
2358
|
-
**Examples**
|
|
2359
|
-
|
|
2360
|
-
```ts
|
|
2361
|
-
import { createWalletClient, custom } from 'viem'
|
|
2362
|
-
import { mainnet } from 'viem/chains'
|
|
2363
|
-
|
|
2364
|
-
const client = createWalletClient({
|
|
2365
|
-
chain: mainnet,
|
|
2366
|
-
transport: custom(window.ethereum),
|
|
2367
|
-
})
|
|
2368
|
-
const signature = await client.signMessage({
|
|
2369
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2370
|
-
message: 'hello world',
|
|
2371
|
-
})
|
|
2372
|
-
```
|
|
2373
|
-
|
|
2374
|
-
```ts
|
|
2375
|
-
// Account Hoisting
|
|
2376
|
-
import { createWalletClient, http } from 'viem'
|
|
2377
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2378
|
-
import { mainnet } from 'viem/chains'
|
|
2379
|
-
|
|
2380
|
-
const client = createWalletClient({
|
|
2381
|
-
account: privateKeyToAccount('0x…'),
|
|
2382
|
-
chain: mainnet,
|
|
2383
|
-
transport: http(),
|
|
2384
|
-
})
|
|
2385
|
-
const signature = await client.signMessage({
|
|
2386
|
-
message: 'hello world',
|
|
2387
|
-
})
|
|
2388
|
-
```
|
|
2389
|
-
|
|
2390
|
-
##### signTransaction
|
|
2391
|
-
|
|
2392
|
-
\<`chainOverride`, `request`\>(`args`) => `Promise`\<[`TransactionSerialized`](https://viem.sh/docs/index.html)\<[`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, `request` *extends* [`LegacyProperties`](https://viem.sh/docs/index.html) ? `"legacy"` : `never` \| `request` *extends* [`EIP1559Properties`](https://viem.sh/docs/index.html) ? `"eip1559"` : `never` \| `request` *extends* [`EIP2930Properties`](https://viem.sh/docs/index.html) ? `"eip2930"` : `never` \| `request` *extends* [`EIP4844Properties`](https://viem.sh/docs/index.html) ? `"eip4844"` : `never` \| `request` *extends* [`EIP7702Properties`](https://viem.sh/docs/index.html) ? `"eip7702"` : `never` \| `request`\[`"type"`\] *extends* `string` \| `undefined` ? `Extract`\<`any`\[`any`\], `string`\> : `never`\>, [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip1559"` ? `` `0x02${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip2930"` ? `` `0x01${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip4844"` ? `` `0x03${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"eip7702"` ? `` `0x04${string}` `` : `never` \| [`GetTransactionType`](https://viem.sh/docs/index.html)\<`request`, ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ... \| ... *extends* ... ? ... : ...\> *extends* `"legacy"` ? [`TransactionSerializedLegacy`](https://viem.sh/docs/index.html) : `never`\>\>
|
|
2393
|
-
|
|
2394
|
-
Signs a transaction.
|
|
2395
|
-
|
|
2396
|
-
- Docs: https://viem.sh/docs/actions/wallet/signTransaction
|
|
2397
|
-
- JSON-RPC Methods:
|
|
2398
|
-
- JSON-RPC Accounts: [`eth_signTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)
|
|
2399
|
-
- Local Accounts: Signs locally. No JSON-RPC request.
|
|
2400
|
-
|
|
2401
|
-
**Examples**
|
|
2402
|
-
|
|
2403
|
-
```ts
|
|
2404
|
-
import { createWalletClient, custom } from 'viem'
|
|
2405
|
-
import { mainnet } from 'viem/chains'
|
|
2406
|
-
|
|
2407
|
-
const client = createWalletClient({
|
|
2408
|
-
chain: mainnet,
|
|
2409
|
-
transport: custom(window.ethereum),
|
|
2410
|
-
})
|
|
2411
|
-
const request = await client.prepareTransactionRequest({
|
|
2412
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2413
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
2414
|
-
value: 1n,
|
|
2415
|
-
})
|
|
2416
|
-
const signature = await client.signTransaction(request)
|
|
2417
|
-
```
|
|
2418
|
-
|
|
2419
|
-
```ts
|
|
2420
|
-
// Account Hoisting
|
|
2421
|
-
import { createWalletClient, http } from 'viem'
|
|
2422
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2423
|
-
import { mainnet } from 'viem/chains'
|
|
2424
|
-
|
|
2425
|
-
const client = createWalletClient({
|
|
2426
|
-
account: privateKeyToAccount('0x…'),
|
|
2427
|
-
chain: mainnet,
|
|
2428
|
-
transport: custom(window.ethereum),
|
|
2429
|
-
})
|
|
2430
|
-
const request = await client.prepareTransactionRequest({
|
|
2431
|
-
to: '0x0000000000000000000000000000000000000000',
|
|
2432
|
-
value: 1n,
|
|
2433
|
-
})
|
|
2434
|
-
const signature = await client.signTransaction(request)
|
|
2435
|
-
```
|
|
2436
|
-
|
|
2437
|
-
##### signTypedData
|
|
2438
|
-
|
|
2439
|
-
\<`typedData`, `primaryType`\>(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
2440
|
-
|
|
2441
|
-
Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
2442
|
-
|
|
2443
|
-
- Docs: https://viem.sh/docs/actions/wallet/signTypedData
|
|
2444
|
-
- JSON-RPC Methods:
|
|
2445
|
-
- JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data#signtypeddata-v4)
|
|
2446
|
-
- Local Accounts: Signs locally. No JSON-RPC request.
|
|
2447
|
-
|
|
2448
|
-
**Examples**
|
|
2449
|
-
|
|
2450
|
-
```ts
|
|
2451
|
-
import { createWalletClient, custom } from 'viem'
|
|
2452
|
-
import { mainnet } from 'viem/chains'
|
|
2453
|
-
|
|
2454
|
-
const client = createWalletClient({
|
|
2455
|
-
chain: mainnet,
|
|
2456
|
-
transport: custom(window.ethereum),
|
|
2457
|
-
})
|
|
2458
|
-
const signature = await client.signTypedData({
|
|
2459
|
-
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
2460
|
-
domain: {
|
|
2461
|
-
name: 'Ether Mail',
|
|
2462
|
-
version: '1',
|
|
2463
|
-
chainId: 1,
|
|
2464
|
-
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
2465
|
-
},
|
|
2466
|
-
types: {
|
|
2467
|
-
Person: [
|
|
2468
|
-
{ name: 'name', type: 'string' },
|
|
2469
|
-
{ name: 'wallet', type: 'address' },
|
|
2470
|
-
],
|
|
2471
|
-
Mail: [
|
|
2472
|
-
{ name: 'from', type: 'Person' },
|
|
2473
|
-
{ name: 'to', type: 'Person' },
|
|
2474
|
-
{ name: 'contents', type: 'string' },
|
|
2475
|
-
],
|
|
2476
|
-
},
|
|
2477
|
-
primaryType: 'Mail',
|
|
2478
|
-
message: {
|
|
2479
|
-
from: {
|
|
2480
|
-
name: 'Cow',
|
|
2481
|
-
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
2482
|
-
},
|
|
2483
|
-
to: {
|
|
2484
|
-
name: 'Bob',
|
|
2485
|
-
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
2486
|
-
},
|
|
2487
|
-
contents: 'Hello, Bob!',
|
|
2488
|
-
},
|
|
2489
|
-
})
|
|
2490
|
-
```
|
|
2491
|
-
|
|
2492
|
-
```ts
|
|
2493
|
-
// Account Hoisting
|
|
2494
|
-
import { createWalletClient, http } from 'viem'
|
|
2495
|
-
import { privateKeyToAccount } from 'viem/accounts'
|
|
2496
|
-
import { mainnet } from 'viem/chains'
|
|
2497
|
-
|
|
2498
|
-
const client = createWalletClient({
|
|
2499
|
-
account: privateKeyToAccount('0x…'),
|
|
2500
|
-
chain: mainnet,
|
|
2501
|
-
transport: http(),
|
|
2502
|
-
})
|
|
2503
|
-
const signature = await client.signTypedData({
|
|
2504
|
-
domain: {
|
|
2505
|
-
name: 'Ether Mail',
|
|
2506
|
-
version: '1',
|
|
2507
|
-
chainId: 1,
|
|
2508
|
-
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
2509
|
-
},
|
|
2510
|
-
types: {
|
|
2511
|
-
Person: [
|
|
2512
|
-
{ name: 'name', type: 'string' },
|
|
2513
|
-
{ name: 'wallet', type: 'address' },
|
|
2514
|
-
],
|
|
2515
|
-
Mail: [
|
|
2516
|
-
{ name: 'from', type: 'Person' },
|
|
2517
|
-
{ name: 'to', type: 'Person' },
|
|
2518
|
-
{ name: 'contents', type: 'string' },
|
|
2519
|
-
],
|
|
2520
|
-
},
|
|
2521
|
-
primaryType: 'Mail',
|
|
2522
|
-
message: {
|
|
2523
|
-
from: {
|
|
2524
|
-
name: 'Cow',
|
|
2525
|
-
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
2526
|
-
},
|
|
2527
|
-
to: {
|
|
2528
|
-
name: 'Bob',
|
|
2529
|
-
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
2530
|
-
},
|
|
2531
|
-
contents: 'Hello, Bob!',
|
|
2532
|
-
},
|
|
2533
|
-
})
|
|
2534
|
-
```
|
|
2535
|
-
|
|
2536
|
-
##### switchChain
|
|
2537
|
-
|
|
2538
|
-
(`args`) => `Promise`\<`void`\>
|
|
2539
|
-
|
|
2540
|
-
Switch the target chain in a wallet.
|
|
2541
|
-
|
|
2542
|
-
- Docs: https://viem.sh/docs/actions/wallet/switchChain
|
|
2543
|
-
- JSON-RPC Methods: [`eth_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-3326)
|
|
2544
|
-
|
|
2545
|
-
**Example**
|
|
2546
|
-
|
|
2547
|
-
```ts
|
|
2548
|
-
import { createWalletClient, custom } from 'viem'
|
|
2549
|
-
import { mainnet, optimism } from 'viem/chains'
|
|
2550
|
-
|
|
2551
|
-
const client = createWalletClient({
|
|
2552
|
-
chain: mainnet,
|
|
2553
|
-
transport: custom(window.ethereum),
|
|
2554
|
-
})
|
|
2555
|
-
await client.switchChain({ id: optimism.id })
|
|
2556
|
-
```
|
|
2557
|
-
|
|
2558
|
-
##### transport
|
|
2559
|
-
|
|
2560
|
-
[`TransportConfig`](https://viem.sh/docs/index.html)\<`string`, [`EIP1193RequestFn`](https://viem.sh/docs/index.html)\> & `Record`\<`string`, `any`\>
|
|
2561
|
-
|
|
2562
|
-
The RPC transport
|
|
2563
|
-
|
|
2564
|
-
##### type
|
|
2565
|
-
|
|
2566
|
-
`string`
|
|
2567
|
-
|
|
2568
|
-
The type of client.
|
|
2569
|
-
|
|
2570
|
-
##### uid
|
|
2571
|
-
|
|
2572
|
-
`string`
|
|
2573
|
-
|
|
2574
|
-
A unique ID for the client.
|
|
2575
|
-
|
|
2576
|
-
##### waitForCallsStatus
|
|
2577
|
-
|
|
2578
|
-
(`parameters`) => `Promise`\<\{ `atomic`: `boolean`; `capabilities?`: \{\[`key`: `string`\]: `any`; \} \| \{\[`key`: `string`\]: `any`; \}; `chainId`: `number`; `id`: `string`; `receipts?`: [`WalletCallReceipt`](https://viem.sh/docs/index.html)\<`bigint`, `"success"` \| `"reverted"`\>[]; `status`: `"pending"` \| `"success"` \| `"failure"` \| `undefined`; `statusCode`: `number`; `version`: `string`; \}\>
|
|
2579
|
-
|
|
2580
|
-
Waits for the status & receipts of a call bundle that was sent via `sendCalls`.
|
|
2581
|
-
|
|
2582
|
-
- Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus
|
|
2583
|
-
- JSON-RPC Methods: [`wallet_getCallsStatus`](https://eips.ethereum.org/EIPS/eip-5792)
|
|
2584
|
-
|
|
2585
|
-
**Example**
|
|
2586
|
-
|
|
2587
|
-
```ts
|
|
2588
|
-
import { createWalletClient, custom } from 'viem'
|
|
2589
|
-
import { mainnet } from 'viem/chains'
|
|
2590
|
-
|
|
2591
|
-
const client = createWalletClient({
|
|
2592
|
-
chain: mainnet,
|
|
2593
|
-
transport: custom(window.ethereum),
|
|
2594
|
-
})
|
|
2595
|
-
|
|
2596
|
-
const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
|
|
2597
|
-
```
|
|
2598
|
-
|
|
2599
|
-
##### watchAsset
|
|
2600
|
-
|
|
2601
|
-
(`args`) => `Promise`\<`boolean`\>
|
|
2602
|
-
|
|
2603
|
-
Adds an EVM chain to the wallet.
|
|
2604
|
-
|
|
2605
|
-
- Docs: https://viem.sh/docs/actions/wallet/watchAsset
|
|
2606
|
-
- JSON-RPC Methods: [`eth_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-747)
|
|
2607
|
-
|
|
2608
|
-
**Example**
|
|
2609
|
-
|
|
2610
|
-
```ts
|
|
2611
|
-
import { createWalletClient, custom } from 'viem'
|
|
2612
|
-
import { mainnet } from 'viem/chains'
|
|
2613
|
-
|
|
2614
|
-
const client = createWalletClient({
|
|
2615
|
-
chain: mainnet,
|
|
2616
|
-
transport: custom(window.ethereum),
|
|
2617
|
-
})
|
|
2618
|
-
const success = await client.watchAsset({
|
|
2619
|
-
type: 'ERC20',
|
|
2620
|
-
options: {
|
|
2621
|
-
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2622
|
-
decimals: 18,
|
|
2623
|
-
symbol: 'WETH',
|
|
2624
|
-
},
|
|
2625
|
-
})
|
|
2626
|
-
```
|
|
2627
|
-
|
|
2628
|
-
##### writeContract
|
|
2629
|
-
|
|
2630
|
-
\<`abi`, `functionName`, `args`, `chainOverride`\>(`args`) => `Promise`\<`` `0x${string}` ``\>
|
|
2631
|
-
|
|
2632
|
-
Executes a write function on a contract.
|
|
2633
|
-
|
|
2634
|
-
- Docs: https://viem.sh/docs/contract/writeContract
|
|
2635
|
-
- Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts
|
|
2636
|
-
|
|
2637
|
-
A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms) is needed to be broadcast in order to change the state.
|
|
2638
|
-
|
|
2639
|
-
Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
|
2640
|
-
|
|
2641
|
-
__Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract#usage) before you execute it.__
|
|
2642
|
-
|
|
2643
|
-
**Examples**
|
|
2644
|
-
|
|
2645
|
-
```ts
|
|
2646
|
-
import { createWalletClient, custom, parseAbi } from 'viem'
|
|
2647
|
-
import { mainnet } from 'viem/chains'
|
|
2648
|
-
|
|
2649
|
-
const client = createWalletClient({
|
|
2650
|
-
chain: mainnet,
|
|
2651
|
-
transport: custom(window.ethereum),
|
|
2652
|
-
})
|
|
2653
|
-
const hash = await client.writeContract({
|
|
2654
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
2655
|
-
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
2656
|
-
functionName: 'mint',
|
|
2657
|
-
args: [69420],
|
|
2658
|
-
})
|
|
2659
|
-
```
|
|
2660
|
-
|
|
2661
|
-
```ts
|
|
2662
|
-
// With Validation
|
|
2663
|
-
import { createWalletClient, custom, parseAbi } from 'viem'
|
|
2664
|
-
import { mainnet } from 'viem/chains'
|
|
2665
|
-
|
|
2666
|
-
const client = createWalletClient({
|
|
2667
|
-
chain: mainnet,
|
|
2668
|
-
transport: custom(window.ethereum),
|
|
2669
|
-
})
|
|
2670
|
-
const { request } = await client.simulateContract({
|
|
2671
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
2672
|
-
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
2673
|
-
functionName: 'mint',
|
|
2674
|
-
args: [69420],
|
|
2675
|
-
}
|
|
2676
|
-
const hash = await client.writeContract(request)
|
|
2677
|
-
```
|
|
2678
|
-
|
|
2679
|
-
##### writeContractSync
|
|
2680
|
-
|
|
2681
|
-
\<`abi`, `functionName`, `args`, `chainOverride`\>(`args`) => `Promise`\<[`TransactionReceipt`](https://viem.sh/docs/index.html)\>
|
|
2682
|
-
|
|
2683
|
-
Executes a write function on a contract synchronously.
|
|
2684
|
-
Returns the transaction receipt.
|
|
2685
|
-
|
|
2686
|
-
- Docs: https://viem.sh/docs/contract/writeContract
|
|
2687
|
-
|
|
2688
|
-
A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms) is needed to be broadcast in order to change the state.
|
|
2689
|
-
|
|
2690
|
-
Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).
|
|
2691
|
-
|
|
2692
|
-
__Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract#usage) before you execute it.__
|
|
2693
|
-
|
|
2694
|
-
**Example**
|
|
2695
|
-
|
|
2696
|
-
```ts
|
|
2697
|
-
import { createWalletClient, custom, parseAbi } from 'viem'
|
|
2698
|
-
import { mainnet } from 'viem/chains'
|
|
2699
|
-
|
|
2700
|
-
const client = createWalletClient({
|
|
2701
|
-
chain: mainnet,
|
|
2702
|
-
transport: custom(window.ethereum),
|
|
2703
|
-
})
|
|
2704
|
-
const receipt = await client.writeContractSync({
|
|
2705
|
-
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
2706
|
-
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
2707
|
-
functionName: 'mint',
|
|
2708
|
-
args: [69420],
|
|
2709
|
-
})
|
|
2710
|
-
```
|
|
2711
|
-
|
|
2712
|
-
### Returns
|
|
2713
|
-
|
|
2714
|
-
[`TokenActions`](../type-aliases/TokenActions.md)
|