Skip to main content
Version: Next

Class: HypercertClient

The HypercertClient is a core class in the hypercerts SDK, providing a high-level interface to interact with the hypercerts system.

It encapsulates the logic for storage, evaluation, indexing, and wallet interactions, abstracting the complexity and providing a simple API for users. The client is read-only if the storage is read-only (no nft.storage/web3.storage keys) or if no walletClient was found.

Example

const config: Partial<HypercertClientConfig> = {
chain: { id: 5 },
};
const client = new HypercertClient(config);

Param

The configuration options for the client.

Implements

Constructors

constructor

new HypercertClient(config): HypercertClient

Creates a new instance of the HypercertClient class.

This constructor takes a config parameter that is used to configure the client. The config parameter should be a HypercertClientConfig object. If the public client cannot be connected, it throws a ClientError.

Parameters

NameTypeDescription
configPartial<HypercertClientConfig>The configuration options for the client.

Returns

HypercertClient

Throws

Will throw a ClientError if the public client cannot be connected.

Defined in

sdk/src/client.ts:55

Properties

_config

Readonly _config: Partial<HypercertClientConfig>

Defined in

sdk/src/client.ts:38


_evaluator

Private Optional _evaluator: HypercertEvaluator

Defined in

sdk/src/client.ts:41


_indexer

Private _indexer: HypercertIndexer

Defined in

sdk/src/client.ts:42


_publicClient

Private _publicClient: Object

Type declaration

NameTypeDescription
accountundefinedThe Account of the Client.
batch?{ multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } }Flags for batch settings.
batch.multicall?boolean | { batchSize?: number | undefined; wait?: number | undefined; }Toggle to enable eth_call multicall aggregation.
cacheTimenumberTime (in ms) that cached data will remain in memory.
call(parameters: CallParameters<undefined | Chain>) => Promise<CallReturnType>Executes a new message call immediately without submitting a transaction to the network. - Docs: https://viem.sh/docs/actions/public/call.html - JSON-RPC Methods: eth_call Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const data = await client.call({ account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', })
chainundefined | ChainChain for the client.
createBlockFilter() => Promise<{ id: `0x${string}` ; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges" ; Parameters: [filterId: `0x${string}`] ; ReturnType: `0x${string}`[] | RpcLog[] }, { Method: "eth_getFilterLogs" ; Parameters: [filterId: `0x${string}`] ; ReturnType: RpcLog[] }, { Method: "eth_uninstallFilter" ; Parameters: [filterId: `0x${string}`] ; ReturnType: boolean }]> ; type: "block" }>Creates a Filter to listen for new block hashes that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createBlockFilter.html - JSON-RPC Methods: eth_newBlockFilter Example ts import { createPublicClient, createBlockFilter, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await createBlockFilter(client) // { id: "0x345a6572337856574a76364e457a4366", type: 'block' }
createContractEventFilter<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>(args: CreateContractEventFilterParameters<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>) => Promise<CreateContractEventFilterReturnType<TAbi, TEventName, TArgs, TStrict, TFromBlock, TToBlock>>Creates a Filter to retrieve event logs that can be used with getFilterChanges or getFilterLogs. - Docs: https://viem.sh/docs/contract/createContractEventFilter.html Example ts import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createContractEventFilter({ abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']), })
createEventFilter<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>(args?: CreateEventFilterParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>) => Promise<{ [K in keyof Filter<"event", TAbiEvents, _EventName, _Args, TStrict, TFromBlock, TToBlock>]: Filter<"event", TAbiEvents, ... 4 more ..., TToBlock>[K]; }>Creates a Filter to listen for new events that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createEventFilter.html - JSON-RPC Methods: eth_newFilter Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createEventFilter({ address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2', })
createPendingTransactionFilter() => Promise<{ id: `0x${string}` ; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges" ; Parameters: [filterId: `0x${string}`] ; ReturnType: `0x${string}`[] | RpcLog[] }, { Method: "eth_getFilterLogs" ; Parameters: [filterId: `0x${string}`] ; ReturnType: RpcLog[] }, { Method: "eth_uninstallFilter" ; Parameters: [filterId: `0x${string}`] ; ReturnType: boolean }]> ; type: "transaction" }>Creates a Filter to listen for new pending transaction hashes that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter.html - JSON-RPC Methods: eth_newPendingTransactionFilter Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createPendingTransactionFilter() // { id: "0x345a6572337856574a76364e457a4366", type: 'transaction' }
estimateContractGas<TChain, TAbi, TFunctionName>(args: EstimateContractGasParameters<TAbi, TFunctionName, TChain, undefined | Account>) => Promise<bigint>Estimates the gas required to successfully execute a contract write function call. - Docs: https://viem.sh/docs/contract/estimateContractGas.html Remarks Internally, uses a Public Client to call the estimateGas action with ABI-encoded data. Example ts import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const gas = await client.estimateContractGas({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint() public']), functionName: 'mint', account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', })
estimateFeesPerGas<TChainOverride, TType>(args?: EstimateFeesPerGasParameters<undefined | Chain, TChainOverride, TType>) => Promise<EstimateFeesPerGasReturnType>Returns an estimate for the fees per gas for a transaction to be included in the next block. - Docs: https://viem.sh/docs/actions/public/estimateFeesPerGas.html Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const maxPriorityFeePerGas = await client.estimateFeesPerGas() // { maxFeePerGas: ..., maxPriorityFeePerGas: ... }
estimateGas(args: EstimateGasParameters<undefined | Chain, undefined | Account>) => Promise<bigint>Estimates the gas necessary to complete a transaction without submitting it to the network. - Docs: https://viem.sh/docs/actions/public/estimateGas.html - JSON-RPC Methods: eth_estimateGas Example ts import { createPublicClient, http, parseEther } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const gasEstimate = await client.estimateGas({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
estimateMaxPriorityFeePerGas<TChainOverride>(args?: { chain: null | TChainOverride }) => Promise<bigint>Returns an estimate for the max priority fee per gas (in wei) for a transaction to be included in the next block. - Docs: https://viem.sh/docs/actions/public/estimateMaxPriorityFeePerGas.html Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas() // 10000000n
extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined, PublicRpcSchema, PublicActions<Transport, undefined | Chain>>) => client) => Client<Transport, undefined | Chain, undefined, PublicRpcSchema, { [K in keyof client]: client[K]; } & PublicActions<Transport, undefined | Chain>>-
getBalance(args: GetBalanceParameters) => Promise<bigint>Returns the balance of an address in wei. - Docs: https://viem.sh/docs/actions/public/getBalance.html - JSON-RPC Methods: eth_getBalance Remarks You can convert the balance to ether units with formatEther. ts const balance = await getBalance(client, { address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', blockTag: 'safe' }) const balanceAsEther = formatEther(balance) // "6.942" Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const balance = await client.getBalance({ address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // 10000000000000000000000n (wei)
getBlock<TIncludeTransactions, TBlockTag>(args?: GetBlockParameters<TIncludeTransactions, TBlockTag>) => Promise<GetBlockReturnType<undefined | Chain, TIncludeTransactions, TBlockTag>>Returns information about a block at a block number, hash, or tag. - Docs: https://viem.sh/docs/actions/public/getBlock.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/fetching-blocks - JSON-RPC Methods: - Calls eth_getBlockByNumber for blockNumber & blockTag. - Calls eth_getBlockByHash for blockHash. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const block = await client.getBlock()
getBlockNumber(args?: GetBlockNumberParameters) => Promise<bigint>Returns the number of the most recent block seen. - Docs: https://viem.sh/docs/actions/public/getBlockNumber.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/fetching-blocks - JSON-RPC Methods: eth_blockNumber Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const blockNumber = await client.getBlockNumber() // 69420n
getBlockTransactionCount(args?: GetBlockTransactionCountParameters) => Promise<number>Returns the number of Transactions at a block number, hash, or tag. - Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount.html - JSON-RPC Methods: - Calls eth_getBlockTransactionCountByNumber for blockNumber & blockTag. - Calls eth_getBlockTransactionCountByHash for blockHash. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const count = await client.getBlockTransactionCount()
getBytecode(args: GetBytecodeParameters) => Promise<GetBytecodeReturnType>Retrieves the bytecode at an address. - Docs: https://viem.sh/docs/contract/getBytecode.html - JSON-RPC Methods: eth_getCode Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const code = await client.getBytecode({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', })
getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const chainId = await client.getChainId() // 1
getContractEvents<TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetContractEventsParameters<TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetContractEventsReturnType<TAbi, TEventName, TStrict, TFromBlock, TToBlock>>Returns a list of event logs emitted by a contract. - Docs: https://viem.sh/docs/actions/public/getContractEvents.html - JSON-RPC Methods: eth_getLogs Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { wagmiAbi } from './abi' const client = createPublicClient({ chain: mainnet, transport: http(), }) const logs = await client.getContractEvents(client, { address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: wagmiAbi, eventName: 'Transfer' })
getEnsAddress(args: { blockNumber?: bigint | undefined; blockTag?: BlockTag | undefined; coinType?: number | undefined; name: string; universalResolverAddress?: `0x${string}` | undefined; }) => Promise<GetEnsAddressReturnType>Gets address for ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsAddress.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/ens Remarks Calls resolve(bytes, bytes) on ENS Universal Resolver Contract. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const ensAddress = await client.getEnsAddress({ name: normalize('wagmi-dev.eth'), }) // '0xd2135CfB216b74109775236E36d4b433F1DF507B'
getEnsAvatar(args: { name: string; blockNumber?: bigint | undefined; blockTag?: BlockTag | undefined; universalResolverAddress?: `0x${string}` | undefined; gatewayUrls?: AssetGatewayUrls | undefined; }) => Promise<GetEnsAvatarReturnType>Gets the avatar of an ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsAvatar.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/ens Remarks Calls getEnsText with key set to 'avatar'. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const ensAvatar = await client.getEnsAvatar({ name: normalize('wagmi-dev.eth'), }) // 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'
getEnsName(args: { blockNumber?: bigint | undefined; blockTag?: BlockTag | undefined; address: `0x${string}`; universalResolverAddress?: `0x${string}` | undefined; }) => Promise<GetEnsNameReturnType>Gets primary name for specified address. - Docs: https://viem.sh/docs/ens/actions/getEnsName.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/ens Remarks Calls reverse(bytes) on ENS Universal Resolver Contract to "reverse resolve" the address to the primary ENS name. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const ensName = await client.getEnsName({ address: '0xd2135CfB216b74109775236E36d4b433F1DF507B', }) // 'wagmi-dev.eth'
getEnsResolver(args: { blockNumber?: bigint | undefined; blockTag?: BlockTag | undefined; name: string; universalResolverAddress?: `0x${string}` | undefined; }) => Promise<`0x${string}`>Gets resolver for ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsResolver.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/ens Remarks Calls findResolver(bytes) on ENS Universal Resolver Contract to retrieve the resolver of an ENS name. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const resolverAddress = await client.getEnsResolver({ name: normalize('wagmi-dev.eth'), }) // '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
getEnsText(args: { blockNumber?: bigint | undefined; blockTag?: BlockTag | undefined; name: string; key: string; universalResolverAddress?: `0x${string}` | undefined; }) => Promise<GetEnsTextReturnType>Gets a text record for specified ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsResolver.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/ens Remarks Calls resolve(bytes, bytes) on ENS Universal Resolver Contract. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const twitterRecord = await client.getEnsText({ name: normalize('wagmi-dev.eth'), key: 'com.twitter', }) // 'wagmi_sh'
getFeeHistory(args: GetFeeHistoryParameters) => Promise<GetFeeHistoryReturnType>Returns a collection of historical gas information. - Docs: https://viem.sh/docs/actions/public/getFeeHistory.html - JSON-RPC Methods: eth_feeHistory Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const feeHistory = await client.getFeeHistory({ blockCount: 4, rewardPercentiles: [25, 75], })
getFilterChanges<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterChangesParameters<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterChangesReturnType<TFilterType, TAbi, TEventName, TStrict, TFromBlock, TToBlock>>Returns a list of logs or hashes based on a Filter since the last time it was called. - Docs: https://viem.sh/docs/actions/public/getFilterChanges.html - JSON-RPC Methods: eth_getFilterChanges Remarks A Filter can be created from the following actions: - createBlockFilter - createContractEventFilter - createEventFilter - createPendingTransactionFilter Depending on the type of filter, the return value will be different: - If the filter was created with createContractEventFilter or createEventFilter, it returns a list of logs. - If the filter was created with createPendingTransactionFilter, it returns a list of transaction hashes. - If the filter was created with createBlockFilter, it returns a list of block hashes. Example ts // Blocks import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createBlockFilter() const hashes = await client.getFilterChanges({ filter }) Example ts // Contract Events import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createContractEventFilter({ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']), eventName: 'Transfer', }) const logs = await client.getFilterChanges({ filter }) Example ts // Raw Events import { createPublicClient, http, parseAbiItem } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createEventFilter({ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'), }) const logs = await client.getFilterChanges({ filter }) Example ts // Transactions import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createPendingTransactionFilter() const hashes = await client.getFilterChanges({ filter })
getFilterLogs<TAbi, TEventName, TStrict, TFromBlock, TToBlock>(args: GetFilterLogsParameters<TAbi, TEventName, TStrict, TFromBlock, TToBlock>) => Promise<GetFilterLogsReturnType<TAbi, TEventName, TStrict, TFromBlock, TToBlock>>Returns a list of event logs since the filter was created. - Docs: https://viem.sh/docs/actions/public/getFilterLogs.html - JSON-RPC Methods: eth_getFilterLogs Remarks getFilterLogs is only compatible with event filters. Example ts import { createPublicClient, http, parseAbiItem } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createEventFilter({ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'), }) const logs = await client.getFilterLogs({ filter })
getGasPrice() => Promise<bigint>Returns the current price of gas (in wei). - Docs: https://viem.sh/docs/actions/public/getGasPrice.html - JSON-RPC Methods: eth_gasPrice Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const gasPrice = await client.getGasPrice()
getLogs<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>(args?: GetLogsParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>) => Promise<GetLogsReturnType<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock>>Returns a list of event logs matching the provided parameters. - Docs: https://viem.sh/docs/actions/public/getLogs.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/filters-and-logs/event-logs - JSON-RPC Methods: eth_getLogs Example ts import { createPublicClient, http, parseAbiItem } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const logs = await client.getLogs()
getProof(args: GetProofParameters) => Promise<GetProofReturnType>Returns the account and storage values of the specified account including the Merkle-proof. - Docs: https://viem.sh/docs/actions/public/getProof.html - JSON-RPC Methods: - Calls eth_getProof Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const block = await client.getProof({ address: '0x...', storageKeys: ['0x...'], })
getStorageAt(args: GetStorageAtParameters) => Promise<GetStorageAtReturnType>Returns the value from a storage slot at a given address. - Docs: https://viem.sh/docs/contract/getStorageAt.html - JSON-RPC Methods: eth_getStorageAt Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { getStorageAt } from 'viem/contract' const client = createPublicClient({ chain: mainnet, transport: http(), }) const code = await client.getStorageAt({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', slot: toHex(0), })
getTransaction<TBlockTag>(args: GetTransactionParameters<TBlockTag>) => Promise<GetTransactionReturnType<undefined | Chain, TBlockTag>>Returns information about a Transaction given a hash or block identifier. - Docs: https://viem.sh/docs/actions/public/getTransaction.html - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions - JSON-RPC Methods: eth_getTransactionByHash Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transaction = await client.getTransaction({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
getTransactionConfirmations(args: GetTransactionConfirmationsParameters<undefined | Chain>) => Promise<bigint>Returns the number of blocks passed (confirmations) since the transaction was processed on a block. - Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations.html - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions - JSON-RPC Methods: eth_getTransactionConfirmations Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const confirmations = await client.getTransactionConfirmations({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
getTransactionCount(args: GetTransactionCountParameters) => Promise<number>Returns the number of Transactions an Account has broadcast / sent. - Docs: https://viem.sh/docs/actions/public/getTransactionCount.html - JSON-RPC Methods: eth_getTransactionCount Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transactionCount = await client.getTransactionCount({ address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
getTransactionReceipt(args: GetTransactionReceiptParameters) => Promise<TransactionReceipt>Returns the Transaction Receipt given a Transaction hash. - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt.html - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/fetching-transactions - JSON-RPC Methods: eth_getTransactionReceipt Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transactionReceipt = await client.getTransactionReceipt({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
keystringA key for the client.
multicall<TContracts, TAllowFailure>(args: MulticallParameters<TContracts, TAllowFailure>) => Promise<MulticallReturnType<TContracts, TAllowFailure>>Similar to readContract, but batches up multiple functions on a contract in a single RPC call via the multicall3 contract. - Docs: https://viem.sh/docs/contract/multicall.html Example ts import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const abi = parseAbi([ 'function balanceOf(address) view returns (uint256)', 'function totalSupply() view returns (uint256)', ]) const result = await client.multicall({ contracts: [ { address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi, functionName: 'balanceOf', args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'], }, { address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi, functionName: 'totalSupply', }, ], }) // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
namestringA name for the client.
pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
readContract<TAbi, TFunctionName>(args: ReadContractParameters<TAbi, TFunctionName>) => Promise<ReadContractReturnType<TAbi, TFunctionName>>Calls a read-only function on a contract, and returns the response. - Docs: https://viem.sh/docs/contract/readContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/reading-contracts Remarks 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. Internally, uses a Public Client to call the call action with ABI-encoded data. Example ts import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' import { readContract } from 'viem/contract' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.readContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function balanceOf(address) view returns (uint256)']), functionName: 'balanceOf', args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'], }) // 424122n
requestEIP1193RequestFn<PublicRpcSchema>Request function wrapped with friendly error handling
sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
simulateContract<TAbi, TFunctionName, TChainOverride>(args: SimulateContractParameters<TAbi, TFunctionName, undefined | Chain, TChainOverride>) => Promise<SimulateContractReturnType<TAbi, TFunctionName, undefined | Chain, TChainOverride>>Simulates/validates a contract interaction. This is useful for retrieving return data and revert reasons of contract write functions. - Docs: https://viem.sh/docs/contract/simulateContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts Remarks This function does not require gas to execute and does not change the state of the blockchain. It is almost identical to readContract, but also supports contract write functions. Internally, uses a Public Client to call the call action with ABI-encoded data. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32) view returns (uint32)']), functionName: 'mint', args: ['69420'], account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
typestringThe type of client.
uidstringA unique ID for the client.
uninstallFilter(args: UninstallFilterParameters) => Promise<boolean>Destroys a Filter that was created from one of the following Actions: - createBlockFilter - createEventFilter - createPendingTransactionFilter - Docs: https://viem.sh/docs/actions/public/uninstallFilter.html - JSON-RPC Methods: eth_uninstallFilter Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { createPendingTransactionFilter, uninstallFilter } from 'viem/public' const filter = await client.createPendingTransactionFilter() const uninstalled = await client.uninstallFilter({ filter }) // true
verifyMessage(args: VerifyMessageParameters) => Promise<boolean>-
verifyTypedData(args: VerifyTypedDataParameters) => Promise<boolean>-
waitForTransactionReceipt(args: WaitForTransactionReceiptParameters<undefined | Chain>) => Promise<TransactionReceipt>Waits for the Transaction to be included on a Block (one confirmation), and then returns the Transaction Receipt. If the Transaction reverts, then the action will throw an error. - Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt.html - Example: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - Polls eth_getTransactionReceipt on each block until it has been processed. - If a Transaction has been replaced: - Calls eth_getBlockByNumber and extracts the transactions - Checks if one of the Transactions is a replacement - If so, calls eth_getTransactionReceipt. Remarks The waitForTransactionReceipt action additionally supports Replacement detection (e.g. sped up Transactions). 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. There are 3 types of Transaction Replacement reasons: - repriced: The gas price has been modified (e.g. different maxFeePerGas) - cancelled: The Transaction has been cancelled (e.g. value === 0n) - replaced: The Transaction has been replaced (e.g. different value or data) Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transactionReceipt = await client.waitForTransactionReceipt({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
watchBlockNumber(args: WatchBlockNumberParameters) => WatchBlockNumberReturnTypeWatches and returns incoming block numbers. - Docs: https://viem.sh/docs/actions/public/watchBlockNumber.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/watching-blocks - JSON-RPC Methods: - When poll: true, calls eth_blockNumber on a polling interval. - When poll: false & WebSocket Transport, uses a WebSocket subscription via eth_subscribe and the "newHeads" event. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = await client.watchBlockNumber({ onBlockNumber: (blockNumber) => console.log(blockNumber), })
watchBlocks<TIncludeTransactions, TBlockTag>(args: WatchBlocksParameters<Transport, undefined | Chain, TIncludeTransactions, TBlockTag>) => WatchBlocksReturnTypeWatches and returns information for incoming blocks. - Docs: https://viem.sh/docs/actions/public/watchBlocks.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/blocks/watching-blocks - JSON-RPC Methods: - When poll: true, calls eth_getBlockByNumber on a polling interval. - When poll: false & WebSocket Transport, uses a WebSocket subscription via eth_subscribe and the "newHeads" event. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = await client.watchBlocks({ onBlock: (block) => console.log(block), })
watchContractEvent<TAbi, TEventName, TStrict>(args: WatchContractEventParameters<TAbi, TEventName, TStrict>) => WatchContractEventReturnTypeWatches and returns emitted contract event logs. - Docs: https://viem.sh/docs/contract/watchContractEvent.html Remarks This Action will batch up all the event logs found within the pollingInterval, and invoke them via onLogs. watchContractEvent will attempt to create an Event Filter 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 instead. Example ts import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = client.watchContractEvent({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']), eventName: 'Transfer', args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' }, onLogs: (logs) => console.log(logs), })
watchEvent<TAbiEvent, TAbiEvents, TStrict>(args: WatchEventParameters<TAbiEvent, TAbiEvents, TStrict>) => WatchEventReturnTypeWatches and returns emitted Event Logs. - Docs: https://viem.sh/docs/actions/public/watchEvent.html - JSON-RPC Methods: - RPC Provider supports eth_newFilter: - Calls eth_newFilter to create a filter (called on initialize). - On a polling interval, it will call eth_getFilterChanges. - RPC Provider does not support eth_newFilter: - Calls eth_getLogs for each block between the polling interval. Remarks This Action will batch up all the Event Logs found within the pollingInterval, and invoke them via onLogs. watchEvent will attempt to create an Event Filter 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 instead. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = client.watchEvent({ onLogs: (logs) => console.log(logs), })
watchPendingTransactions(args: WatchPendingTransactionsParameters<Transport>) => WatchPendingTransactionsReturnTypeWatches and returns pending transaction hashes. - Docs: https://viem.sh/docs/actions/public/watchPendingTransactions.html - JSON-RPC Methods: - When poll: true - Calls eth_newPendingTransactionFilter to initialize the filter. - Calls eth_getFilterChanges on a polling interval. - When poll: false & WebSocket Transport, uses a WebSocket subscription via eth_subscribe and the "newPendingTransactions" event. Remarks This Action will batch up all the pending transactions found within the pollingInterval, and invoke them via onTransactions. Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = await client.watchPendingTransactions({ onTransactions: (hashes) => console.log(hashes), })

Defined in

sdk/src/client.ts:43


_storage

Private _storage: HypercertsStorage

Defined in

sdk/src/client.ts:39


_walletClient

Private Optional _walletClient: Object

Type declaration

NameTypeDescription
accountundefined | AccountThe Account of the Client.
addChain(args: AddChainParameters) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain.html - JSON-RPC Methods: eth_addEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
batch?{ multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } }Flags for batch settings.
batch.multicall?boolean | { batchSize?: number | undefined; wait?: number | undefined; }Toggle to enable eth_call multicall aggregation.
cacheTimenumberTime (in ms) that cached data will remain in memory.
chainundefined | ChainChain for the client.
deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/deploying-contracts Example ts import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in keyof client]: client[K]; } & WalletActions<undefined | Chain, undefined | Account>>-
getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses.html - JSON-RPC Methods: eth_accounts Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId.html - JSON-RPC Methods: eth_chainId Example ts import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions.html - JSON-RPC Methods: wallet_getPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
keystringA key for the client.
namestringA name for the client.
pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest.html Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) Example ts // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses.html - JSON-RPC Methods: eth_requestAccounts 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). 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. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
requestPermissions(args: { [x: string]: Record<string, any>; eth_accounts: Record<string, any>; }) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions.html - JSON-RPC Methods: wallet_requestPermissions Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction.html - JSON-RPC Method: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) Example ts // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage.html - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) Example ts // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) Example ts // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) Example ts // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
switchChain(args: SwitchChainParameters) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
typestringThe type of client.
uidstringA unique ID for the client.
watchAsset(args: WatchAssetParams) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset.html - JSON-RPC Methods: eth_switchEthereumChain Example ts import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts 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 is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. 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 before you execute it. Example ts import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) Example ts // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)

Defined in

sdk/src/client.ts:44


readonly

readonly: boolean

Whether the client is in read-only mode.

Implementation of

HypercertClientInterface.readonly

Defined in

sdk/src/client.ts:45

Accessors

config

get config(): Partial<HypercertClientConfig>

Gets the config for the client.

Returns

Partial<HypercertClientConfig>

The client config.

Defined in

sdk/src/client.ts:79


contract

get contract(): GetContractReturnType<({ anonymous?: undefined = false; inputs: never[] = []; name?: undefined = "balanceOf"; outputs?: undefined ; stateMutability: string = "nonpayable"; type: string = "constructor" } | { anonymous?: undefined = false; inputs: never[] = []; name: string = "AlreadyClaimed"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "error" } | { anonymous: boolean = false; inputs: { indexed: boolean = false; internalType: string = "address"; name: string = "previousAdmin"; type: string = "address" }[] ; name: string = "AdminChanged"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "event" } | { anonymous?: undefined = false; inputs: { internalType: string = "address"; name: string = "account"; type: string = "address" }[] ; name: string = "balanceOf"; outputs: { internalType: string = "uint256"; name: string = ""; type: string = "uint256" }[] ; stateMutability: string = "view"; type: string = "function" })[]>

Gets the HypercertMinter contract used by the client.

Returns

GetContractReturnType<({ anonymous?: undefined = false; inputs: never[] = []; name?: undefined = "balanceOf"; outputs?: undefined ; stateMutability: string = "nonpayable"; type: string = "constructor" } | { anonymous?: undefined = false; inputs: never[] = []; name: string = "AlreadyClaimed"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "error" } | { anonymous: boolean = false; inputs: { indexed: boolean = false; internalType: string = "address"; name: string = "previousAdmin"; type: string = "address" }[] ; name: string = "AdminChanged"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "event" } | { anonymous?: undefined = false; inputs: { internalType: string = "address"; name: string = "account"; type: string = "address" }[] ; name: string = "balanceOf"; outputs: { internalType: string = "uint256"; name: string = ""; type: string = "uint256" }[] ; stateMutability: string = "view"; type: string = "function" })[]>

The contract.

Implementation of

HypercertClientInterface.contract

Defined in

sdk/src/client.ts:103


indexer

get indexer(): HypercertIndexer

Gets the indexer for the client.

Returns

HypercertIndexer

The indexer.

Implementation of

HypercertClientInterface.indexer

Defined in

sdk/src/client.ts:95


storage

get storage(): HypercertsStorage

Gets the storage layer for the client.

Returns

HypercertsStorage

The storage layer.

Implementation of

HypercertClientInterface.storage

Defined in

sdk/src/client.ts:87

Methods

batchMintClaimFractionsFromAllowlists

batchMintClaimFractionsFromAllowlists(claimIds, units, proofs, roots?, overrides?): Promise<undefined | `0x${string}`>

Mints multiple claim fractions from allowlists in a batch.

This method first retrieves the wallet client and account using the getWallet method. If the roots are provided, it verifies each proof using the verifyMerkleProofs function. If any of the proofs are invalid, it throws an InvalidOrMissingError. It then simulates a contract call to the batchMintClaimsFromAllowlists function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameTypeDescription
claimIdsbigint[]The IDs of the claims to mint.
unitsbigint[]The units of each claim to mint.
proofs(`0x${string}` | Uint8Array)[][]The proofs for each claim.
roots?(`0x${string}` | Uint8Array)[]The roots of each proof. If provided, they are used to verify the proofs.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw an InvalidOrMissingError if any of the proofs are invalid.

Implementation of

HypercertClientInterface.batchMintClaimFractionsFromAllowlists

Defined in

sdk/src/client.ts:459


batchTransferFractions

batchTransferFractions(fractionIds, to, overrides?): Promise<undefined | `0x${string}`>

Transfers multiple claim fractions to a new owner.

This method first retrieves the wallet client and account using the getWallet method. It then simulates a contract call to the safeBatchTransferFrom function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameType
fractionIdsbigint[]
to`0x${string}`
overrides?SupportedOverrides

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Implementation of

HypercertClientInterface.batchTransferFractions

Defined in

sdk/src/client.ts:210


burnClaimFraction

burnClaimFraction(claimId, overrides?): Promise<undefined | `0x${string}`>

Burns a claim fraction.

This method first retrieves the wallet client and account using the getWallet method. It then retrieves the owner of the claim using the ownerOf method of the read contract. If the claim is not owned by the account, it throws a ClientError. It then simulates a contract call to the burnFraction function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameTypeDescription
claimIdbigintThe ID of the claim to burn.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw a ClientError if the claim is not owned by the account.

Implementation of

HypercertClientInterface.burnClaimFraction

Defined in

sdk/src/client.ts:382


createAllowlist

createAllowlist(allowList, metaData, totalUnits, transferRestriction, overrides?): Promise<undefined | `0x${string}`>

Creates an allowlist.

This method first validates the provided allowlist and metadata using the validateAllowlist and validateMetaData functions respectively. If either is invalid, it throws a MalformedDataError. It then creates an allowlist from the provided entries and stores it on IPFS using the storeData method of the storage client. After that, it stores the metadata (including the CID of the allowlist) on IPFS using the storeMetadata method of the storage client. Finally, it simulates a contract call to the createAllowlist function with the provided parameters and the stored metadata CID, and submits the request using the submitRequest method.

Parameters

NameTypeDescription
allowListAllowlistEntry[]The entries for the allowlist.
metaDataHypercertMetadataThe metadata for the claim.
totalUnitsbigintThe total units for the claim.
transferRestrictionTransferRestrictionsThe transfer restrictions for the claim.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw a MalformedDataError if the provided allowlist or metadata is invalid.

Implementation of

HypercertClientInterface.createAllowlist

Defined in

sdk/src/client.ts:243


getCleanedOverrides

getCleanedOverrides(overrides?): Object

Parameters

NameType
overrides?SupportedOverrides

Returns

Object

Defined in

sdk/src/client.ts:499


getContractConfig

getContractConfig(): GetContractReturnType<({ anonymous?: undefined = false; inputs: never[] = []; name?: undefined = "balanceOf"; outputs?: undefined ; stateMutability: string = "nonpayable"; type: string = "constructor" } | { anonymous?: undefined = false; inputs: never[] = []; name: string = "AlreadyClaimed"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "error" } | { anonymous: boolean = false; inputs: { indexed: boolean = false; internalType: string = "address"; name: string = "previousAdmin"; type: string = "address" }[] ; name: string = "AdminChanged"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "event" } | { anonymous?: undefined = false; inputs: { internalType: string = "address"; name: string = "account"; type: string = "address" }[] ; name: string = "balanceOf"; outputs: { internalType: string = "uint256"; name: string = ""; type: string = "uint256" }[] ; stateMutability: string = "view"; type: string = "function" })[], undefined | Client<Transport, undefined | Chain>, undefined | Client<Transport, undefined | Chain, undefined | Account>, `0x${string}`, string, string, string, false>

Returns

GetContractReturnType<({ anonymous?: undefined = false; inputs: never[] = []; name?: undefined = "balanceOf"; outputs?: undefined ; stateMutability: string = "nonpayable"; type: string = "constructor" } | { anonymous?: undefined = false; inputs: never[] = []; name: string = "AlreadyClaimed"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "error" } | { anonymous: boolean = false; inputs: { indexed: boolean = false; internalType: string = "address"; name: string = "previousAdmin"; type: string = "address" }[] ; name: string = "AdminChanged"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "event" } | { anonymous?: undefined = false; inputs: { internalType: string = "address"; name: string = "account"; type: string = "address" }[] ; name: string = "balanceOf"; outputs: { internalType: string = "uint256"; name: string = ""; type: string = "uint256" }[] ; stateMutability: string = "view"; type: string = "function" })[], undefined | Client<Transport, undefined | Chain>, undefined | Client<Transport, undefined | Chain, undefined | Account>, `0x${string}`, string, string, string, false>

Defined in

sdk/src/client.ts:490


getTransferRestrictions

getTransferRestrictions(fractionId): Promise<TransferRestrictions>

Gets the TransferRestrictions for a claim.

This method first retrieves the read contract using the getContract method. It then simulates a contract call to the readTransferRestriction function with the provided fraction ID.

Parameters

NameType
fractionIdbigint

Returns

Promise<TransferRestrictions>

a Promise that resolves to the applicable transfer restrictions.

Implementation of

HypercertClientInterface.getTransferRestrictions

Defined in

sdk/src/client.ts:162


getWallet

getWallet(): Object

Returns

Object

NameType
accountAccount
walletClient{ account: undefined | Account ; addChain: (args: AddChainParameters) => Promise<void> ; batch?: { multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } } ; cacheTime: number ; chain: undefined | Chain ; deployContract: <TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`> ; extend: <client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in keyof client]: client[K]; } & WalletActions<undefined | Chain, undefined | Account>> ; getAddresses: () => Promise<GetAddressesReturnType> ; getChainId: () => Promise<number> ; getPermissions: () => Promise<GetPermissionsReturnType> ; key: string ; name: string ; pollingInterval: number ; prepareTransactionRequest: <TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType> ; request: EIP1193RequestFn<WalletRpcSchema> ; requestAddresses: () => Promise<RequestAddressesReturnType> ; requestPermissions: (args: { [x: string]: Record<string, any>; eth_accounts: Record<string, any>; }) => Promise<RequestPermissionsReturnType> ; sendRawTransaction: (args: SendRawTransactionParameters) => Promise<`0x${string}`> ; sendTransaction: <TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`> ; signMessage: (args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`> ; signTransaction: <TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`> ; signTypedData: <TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`> ; switchChain: (args: SwitchChainParameters) => Promise<void> ; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any> ; type: string ; uid: string ; watchAsset: (args: WatchAssetParams) => Promise<boolean> ; writeContract: <TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`> }
walletClient.accountundefined | Account
walletClient.addChain(args: AddChainParameters) => Promise<void>
walletClient.batch?{ multicall?: boolean | { batchSize?: number | undefined; wait?: number | undefined; } }
walletClient.batch.multicall?boolean | { batchSize?: number | undefined; wait?: number | undefined; }
walletClient.cacheTimenumber
walletClient.chainundefined | Chain
walletClient.deployContract<TAbi, TChainOverride>(args: DeployContractParameters<TAbi, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>
walletClient.extend<client>(fn: (client: Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, WalletActions<undefined | Chain, undefined | Account>>) => client) => Client<Transport, undefined | Chain, undefined | Account, WalletRpcSchema, { [K in keyof client]: client[K]; } & WalletActions<undefined | Chain, undefined | Account>>
walletClient.getAddresses() => Promise<GetAddressesReturnType>
walletClient.getChainId() => Promise<number>
walletClient.getPermissions() => Promise<GetPermissionsReturnType>
walletClient.keystring
walletClient.namestring
walletClient.pollingIntervalnumber
walletClient.prepareTransactionRequest<TChainOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<PrepareTransactionRequestReturnType>
walletClient.requestEIP1193RequestFn<WalletRpcSchema>
walletClient.requestAddresses() => Promise<RequestAddressesReturnType>
walletClient.requestPermissions(args: { [x: string]: Record<string, any>; eth_accounts: Record<string, any>; }) => Promise<RequestPermissionsReturnType>
walletClient.sendRawTransaction(args: SendRawTransactionParameters) => Promise<`0x${string}`>
walletClient.sendTransaction<TChainOverride>(args: SendTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>
walletClient.signMessage(args: SignMessageParameters<undefined | Account>) => Promise<`0x${string}`>
walletClient.signTransaction<TChainOverride>(args: SignTransactionParameters<undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>
walletClient.signTypedData<TTypedData, TPrimaryType>(args: SignTypedDataParameters<TTypedData, TPrimaryType, undefined | Account>) => Promise<`0x${string}`>
walletClient.switchChain(args: SwitchChainParameters) => Promise<void>
walletClient.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>
walletClient.typestring
walletClient.uidstring
walletClient.watchAsset(args: WatchAssetParams) => Promise<boolean>
walletClient.writeContract<TAbi, TFunctionName, TChainOverride>(args: WriteContractParameters<TAbi, TFunctionName, undefined | Chain, undefined | Account, TChainOverride>) => Promise<`0x${string}`>

Defined in

sdk/src/client.ts:509


mergeFractionUnits

mergeFractionUnits(fractionIds, overrides?): Promise<undefined | `0x${string}`>

Merges multiple fractions into a single fraction.

This method first retrieves the wallet client and account using the getWallet method. It then retrieves the owner of each fraction using the ownerOf method of the read contract. If any of the fractions are not owned by the account, it throws a ClientError. It then simulates a contract call to the mergeFractions function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameTypeDescription
fractionIdsbigint[]The IDs of the fractions to merge.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw a ClientError if any of the fractions are not owned by the account.

Implementation of

HypercertClientInterface.mergeFractionUnits

Defined in

sdk/src/client.ts:341


mintClaim

mintClaim(metaData, totalUnits, transferRestriction, overrides?): Promise<undefined | `0x${string}`>

Mints a new claim.

This method first validates the provided metadata using the validateMetaData function. If the metadata is invalid, it throws a MalformedDataError. It then stores the metadata on IPFS using the storeMetadata method of the storage client. After that, it simulates a contract call to the mintClaim function with the provided parameters and the stored metadata CID to validate the transaction. Finally, it submits the request using the submitRequest method.

Parameters

NameTypeDescription
metaDataHypercertMetadataThe metadata for the claim.
totalUnitsbigintThe total units for the claim.
transferRestrictionTransferRestrictionsThe transfer restrictions for the claim.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw a MalformedDataError if the provided metadata is invalid.

Implementation of

HypercertClientInterface.mintClaim

Defined in

sdk/src/client.ts:127


mintClaimFractionFromAllowlist

mintClaimFractionFromAllowlist(claimId, units, proof, root?, overrides?): Promise<undefined | `0x${string}`>

Mints a claim fraction from an allowlist.

This method first retrieves the wallet client and account using the getWallet method. It then verifies the provided proof using the verifyMerkleProof function. If the proof is invalid, it throws an InvalidOrMissingError. It then simulates a contract call to the mintClaimFromAllowlist function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameTypeDescription
claimIdbigintThe ID of the claim to mint.
unitsbigintThe units of the claim to mint.
proof(`0x${string}` | Uint8Array)[]The proof for the claim.
root?`0x${string}` | Uint8ArrayThe root of the proof. If provided, it is used to verify the proof.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw an InvalidOrMissingError if the proof is invalid.

Implementation of

HypercertClientInterface.mintClaimFractionFromAllowlist

Defined in

sdk/src/client.ts:415


simulateRequest

simulateRequest(account, functionName, args, overrides?): Promise<{ abi: Narrow<{ anonymous?: undefined = false; inputs: never[] = []; name?: undefined = "balanceOf"; outputs?: undefined ; stateMutability: string = "nonpayable"; type: string = "constructor" } | { anonymous?: undefined = false; inputs: never[] = []; name: string = "AlreadyClaimed"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "error" } | { anonymous: boolean = false; inputs: { indexed: boolean = false; internalType: string = "address"; name: string = "previousAdmin"; type: string = "address" }[] ; name: string = "AdminChanged"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "event" } | { anonymous?: undefined = false; inputs: { internalType: string = "address"; name: string = "account"; type: string = "address" }[] ; name: string = "balanceOf"; outputs: { internalType: string = "uint256"; name: string = ""; type: string = "uint256" }[] ; stateMutability: string = "view"; type: string = "function" }>[] ; accessList?: AccessList ; account: `0x${string}` | Account ; address: `0x${string}` ; args?: readonly unknown[] ; chain: undefined ; dataSuffix?: `0x${string}` ; functionName: string ; gas?: bigint ; gasPrice?: bigint ; maxFeePerGas?: bigint ; maxPriorityFeePerGas?: bigint ; nonce?: number ; type?: "legacy" | "eip2930" | "eip1559" ; value?: bigint }>

Parameters

NameType
accountAccount
functionNamestring
argsunknown[]
overrides?SupportedOverrides

Returns

Promise<{ abi: Narrow<{ anonymous?: undefined = false; inputs: never[] = []; name?: undefined = "balanceOf"; outputs?: undefined ; stateMutability: string = "nonpayable"; type: string = "constructor" } | { anonymous?: undefined = false; inputs: never[] = []; name: string = "AlreadyClaimed"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "error" } | { anonymous: boolean = false; inputs: { indexed: boolean = false; internalType: string = "address"; name: string = "previousAdmin"; type: string = "address" }[] ; name: string = "AdminChanged"; outputs?: undefined ; stateMutability?: undefined = "view"; type: string = "event" } | { anonymous?: undefined = false; inputs: { internalType: string = "address"; name: string = "account"; type: string = "address" }[] ; name: string = "balanceOf"; outputs: { internalType: string = "uint256"; name: string = ""; type: string = "uint256" }[] ; stateMutability: string = "view"; type: string = "function" }>[] ; accessList?: AccessList ; account: `0x${string}` | Account ; address: `0x${string}` ; args?: readonly unknown[] ; chain: undefined ; dataSuffix?: `0x${string}` ; functionName: string ; gas?: bigint ; gasPrice?: bigint ; maxFeePerGas?: bigint ; maxPriorityFeePerGas?: bigint ; nonce?: number ; type?: "legacy" | "eip2930" | "eip1559" ; value?: bigint }>

Defined in

sdk/src/client.ts:519


splitFractionUnits

splitFractionUnits(fractionId, fractions, overrides?): Promise<undefined | `0x${string}`>

Splits a fraction into multiple fractions.

This method first retrieves the wallet client and account using the getWallet method. It then retrieves the owner and total units of the fraction using the ownerOf and unitsOf methods of the read contract. If the fraction is not owned by the account, it throws a ClientError. It then checks if the sum of the provided fractions is equal to the total units of the fraction. If not, it throws a ClientError. Finally, it simulates a contract call to the splitFraction function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameTypeDescription
fractionIdbigintThe ID of the fraction to split.
fractionsbigint[]The fractions to split the fraction into.
overrides?SupportedOverridesOptional overrides for the contract call.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Throws

Will throw a ClientError if the fraction is not owned by the account or if the sum of the fractions is not equal to the total units of the fraction.

Implementation of

HypercertClientInterface.splitFractionUnits

Defined in

sdk/src/client.ts:296


submitRequest

submitRequest(request): Promise<`0x${string}`>

Submits a contract request.

This method submits a contract request using the writeContract method of the wallet client. If the request fails, it throws a ClientError.

Parameters

NameTypeDescription
requestanyThe contract request to submit.

Returns

Promise<`0x${string}`>

A promise that resolves to the hash of the submitted request.

Throws

Will throw a ClientError if the request fails.

Defined in

sdk/src/client.ts:550


transferFraction

transferFraction(fractionId, to, overrides?): Promise<undefined | `0x${string}`>

Transfers a claim fraction to a new owner.

This method first retrieves the wallet client and account using the getWallet method. It then simulates a contract call to the safeTransferFrom function with the provided parameters and the account, and submits the request using the submitRequest method.

Parameters

NameType
fractionIdbigint
tostring
overrides?SupportedOverrides

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the transaction hash.

Implementation of

HypercertClientInterface.transferFraction

Defined in

sdk/src/client.ts:182