sdk-js

@nevermined-io/sdk

@nevermined-io/sdk - v3.0.44

Table of contents

References

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

References

LoggerInstance

Renames and re-exports Logger

Type Aliases

ConditionMethod

Ƭ ConditionMethod: "fulfill" | "fulfillForDelegate"

Defined in

src/types/ContractTypes.ts:10


ConditionType

Ƭ ConditionType: "lockPayment" | "escrowPayment" | "nftHolder" | "transferNFT"

Defined in

src/types/DDOTypes.ts:652


EncryptionMethod

Ƭ EncryptionMethod: "PSK-RSA" | "PSK-ECDSA"

Defined in

src/constants/AssetConstants.ts:4


EventResult

Ƭ EventResult: Promise<any[]>

Defined in

src/types/EventTypes.ts:25


NeverminedNFTType

Ƭ NeverminedNFTType: NeverminedNFT721Type | NeverminedNFT1155Type

Defined in

src/types/GeneralTypes.ts:31


ParameterType

Ƭ ParameterType: string | number | number[] | NvmAccount | BabyjubPublicKey | Service | ServiceType | TxParameters

Defined in

src/keeper/contracts/templates/AgreementTemplate.abstract.ts:23


PricedMetadataInformation

Ƭ PricedMetadataInformation: Object

Type declaration

Name Type
attributes { additionalInformation: { priceHighestDenomination: number } ; main: { price: string } }
attributes.additionalInformation { priceHighestDenomination: number }
attributes.additionalInformation.priceHighestDenomination number
attributes.main { price: string }
attributes.main.price string

Defined in

src/types/DDOTypes.ts:690


ProvenanceEvent

Ƭ ProvenanceEvent<T>: T extends WAS_GENERATED_BY ? WasGeneratedByEvent : T extends USED ? UsedEvent : T extends WAS_DERIVED_FROM ? WasDerivedFromEvent : T extends WAS_ASSOCIATED_WITH ? WasAssociatedWithEvent : T extends ACTED_ON_BEHALF ? ActedOnBehalfEvent : WasGeneratedByEvent | UsedEvent | WasDerivedFromEvent | WasAssociatedWithEvent | ActedOnBehalfEvent

Type parameters

Name Type
T extends ProvenanceMethod | any = any

Defined in

src/keeper/contracts/Provenance.ts:80


Service

Ƭ Service<T>: T extends "authorization" ? ServiceAuthorization : T extends "metadata" ? ServiceMetadata : T extends "nft-access" ? ServiceNFTAccess : T extends "nft-sales" ? ServiceNFTSales : T extends "access" ? ServiceAccess : T extends "compute" ? ServiceCompute : T extends "default" ? ServiceCommon : ServiceCommon

Type parameters

Name Type
T extends ServiceType | "default" = "default"

Defined in

src/types/DDOTypes.ts:811


ServiceType

Ƭ ServiceType: "authorization" | "metadata" | "access" | "compute" | "workflow" | "nft-access" | "nft-sales" | "nft-sales-proof"

Defined in

src/types/DDOTypes.ts:654

Variables

ConditionStateNames

Const ConditionStateNames: string[]

Defined in

src/types/ContractTypes.ts:8


DEFAULT_ENCRYPTION_METHOD

Const DEFAULT_ENCRYPTION_METHOD: EncryptionMethod

Defined in

src/constants/AssetConstants.ts:7


DEFAULT_REGISTRATION_ACTIVITY_ID

Const DEFAULT_REGISTRATION_ACTIVITY_ID: "AssetRegistration"

Identifies the default Provenance Activity Id to be recorded on-chain in the DIDRegistry Smart Contract when an asset is registered. It associates to the new DID created the ‘Asset Registration’ activity. (@see https://docs.nevermined.io/docs/architecture/specs/Spec-PROVENANCE#provenance-relations)

Defined in

src/keeper/contracts/Provenance.ts:7


DEPENDENCIES_RELEASE_CONDITION

Const DEPENDENCIES_RELEASE_CONDITION: string[]

Defined in

src/ddo/DDO.ts:39


DefaultPaymentAttributes

Const DefaultPaymentAttributes: PaymentAttributes[]

Defined in

src/types/DDOTypes.ts:74


Logger

Const Logger: Logger

Defined in

src/models/Logger.ts:43


NETWORK_FEE_DENOMINATOR

Const NETWORK_FEE_DENOMINATOR: 10000n

Defined in

src/constants/AssetConstants.ts:1


SALES_SERVICES

Const SALES_SERVICES: string[]

Defined in

src/ddo/DDO.ts:37


ZeroAddress

Const ZeroAddress: "0x0000000000000000000000000000000000000000"

Defined in

src/constants/AssetConstants.ts:10


apiPath

Const apiPath: "/api/v1/metadata/assets/ddo"

Defined in

src/services/metadata/MetadataService.ts:8


defaultNeverminedNFTType

Const defaultNeverminedNFTType: Object

Type declaration

Name Type
1155 NeverminedNFT1155Type
721 NeverminedNFT721Type

Defined in

src/types/GeneralTypes.ts:40


ercOfNeverminedNFTType

Const ercOfNeverminedNFTType: Object

Type declaration

Name Type
nft1155 ERCType
nft1155-credit ERCType
nft721 ERCType
nft721-subscription ERCType

Defined in

src/types/GeneralTypes.ts:33


serviceIndex

Const serviceIndex: Object

Type declaration

Name Type
access number
access-proof number
authorization number
compute number
metadata number
nft-access number
nft-access-proof number
nft-sales number
nft-sales-proof number
nft721-access number
nft721-access-proof number
nft721-sales number
nft721-sales-proof number
workflow number

Defined in

src/types/DDOTypes.ts:664


servicePath

Const servicePath: "/api/v1/metadata/assets/service"

Defined in

src/services/metadata/MetadataService.ts:9

Functions

_sleep

_sleep(ms): Promise<unknown>

Parameters

Name Type
ms number

Returns

Promise<unknown>

Defined in

src/common/helpers.ts:47


buildQuery

buildQuery(url, query?): any

Parameters

Name Type
url string
query? SearchQuery

Returns

any

Defined in

src/common/helpers.ts:7


checkContractExists

checkContractExists(contractAddress, client): Promise<boolean>

Given a contract address it checks if the contract exists on the blockchain.

Parameters

Name Type Description
contractAddress string the contract address
client Object the client to interact with the blockchain
client.account undefined The Account of the Client.
client.batch? Object Flags for batch settings.
client.batch.multicall? boolean | { batchSize?: number ; wait?: number } Toggle to enable eth_call multicall aggregation.
client.cacheTime number Time (in ms) that cached data will remain in memory.
client.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 - 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', })
client.ccipRead? false | { request?: (parameters: CcipRequestParameters) => Promise<`0x${string}`> } CCIP Read configuration.
client.chain undefined | Chain Chain for the client.
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 - 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' }
client.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 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)']), })
client.createEventFilter <TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>(args?: CreateEventFilterParameters<TAbiEvent, TAbiEvents, TStrict, TFromBlock, TToBlock, _EventName, _Args>) => Promise<{ [K in string | number | symbol]: Filter<“event”, TAbiEvents, _EventName, _Args, TStrict, TFromBlock, TToBlock>[K] }> Creates a Filter to listen for new events that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createEventFilter - 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', })
client.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 - 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' }
client.estimateContractGas <TChain, abi, functionName, args>(args: EstimateContractGasParameters<abi, functionName, args, TChain>) => Promise<bigint> Estimates the gas required to successfully execute a contract write function call. - Docs: https://viem.sh/docs/contract/estimateContractGas 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', })
client.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 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: ... }
client.estimateGas (args: EstimateGasParameters<undefined | Chain>) => Promise<bigint> Estimates the gas necessary to complete a transaction without submitting it to the network. - Docs: https://viem.sh/docs/actions/public/estimateGas - 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'), })
client.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 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
client.extend <client>(fn: (client: Client<Transport, undefined | Chain, undefined, PublicRpcSchema, PublicActions<Transport, undefined | Chain>>) => client) => Client<Transport, undefined | Chain, undefined, PublicRpcSchema, { [K in string | number | symbol]: client[K] } & PublicActions<Transport, undefined | Chain>> -
client.getBalance (args: GetBalanceParameters) => Promise<bigint> Returns the balance of an address in wei. - Docs: https://viem.sh/docs/actions/public/getBalance - 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)
client.getBlobBaseFee () => Promise<bigint> Returns the base fee per blob gas in wei. - Docs: https://viem.sh/docs/actions/public/getBlobBaseFee - JSON-RPC Methods: eth_blobBaseFee Example ts import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { getBlobBaseFee } from 'viem/public' const client = createPublicClient({ chain: mainnet, transport: http(), }) const blobBaseFee = await client.getBlobBaseFee()
client.getBlock <TIncludeTransactions, TBlockTag>(args?: GetBlockParameters<TIncludeTransactions, TBlockTag>) => Promise<{ baseFeePerGas: null | bigint ; blobGasUsed: bigint ; difficulty: bigint ; excessBlobGas: bigint ; extraData: `0x${string}` ; gasLimit: bigint ; gasUsed: bigint ; hash: TBlockTag extends "pending" ? null : `0x${string}` ; logsBloom: TBlockTag extends "pending" ? null : `0x${string}` ; miner: `0x${string}` ; mixHash: `0x${string}` ; nonce: TBlockTag extends "pending" ? null : `0x${string}` ; number: TBlockTag extends "pending" ? null : bigint ; parentHash: `0x${string}` ; receiptsRoot: `0x${string}` ; sealFields: `0x${string}`[] ; sha3Uncles: `0x${string}` ; size: bigint ; stateRoot: `0x${string}` ; timestamp: bigint ; totalDifficulty: null | bigint ; transactions: TIncludeTransactions extends true ? ({ accessList?: undefined ; blobVersionedHashes?: undefined ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "legacy" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity?: undefined } | { accessList: AccessList ; blobVersionedHashes?: undefined ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "eip2930" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity: number } | { accessList: AccessList ; blobVersionedHashes?: undefined ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "eip1559" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity: number } | { accessList: AccessList ; blobVersionedHashes: `0x${string}`[] ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "eip4844" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity: number })[] : `0x${string}`[] ; transactionsRoot: `0x${string}` ; uncles: `0x${string}`[] ; withdrawals?: Withdrawal[] ; withdrawalsRoot?: `0x${string}` }> Returns information about a block at a block number, hash, or tag. - Docs: https://viem.sh/docs/actions/public/getBlock - Examples: https://stackblitz.com/github/wevm/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()
client.getBlockNumber (args?: GetBlockNumberParameters) => Promise<bigint> Returns the number of the most recent block seen. - Docs: https://viem.sh/docs/actions/public/getBlockNumber - Examples: https://stackblitz.com/github/wevm/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
client.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 - 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()
client.getBytecode (args: GetBytecodeParameters) => Promise<GetBytecodeReturnType> Retrieves the bytecode at an address. - Docs: https://viem.sh/docs/contract/getBytecode - 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', })
client.getChainId () => Promise<number> Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - 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
client.getContractEvents <abi, eventName, strict, fromBlock, toBlock>(args: GetContractEventsParameters<abi, eventName, strict, fromBlock, toBlock>) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>> Returns a list of event logs emitted by a contract. - Docs: https://viem.sh/docs/actions/public/getContractEvents - 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' })
client.getEnsAddress (args: { blockNumber?: bigint ; blockTag?: BlockTag ; coinType?: number ; gatewayUrls?: string[] ; name: string ; strict?: boolean ; universalResolverAddress?: `0x${string}` }) => Promise<GetEnsAddressReturnType> Gets address for ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsAddress - Examples: https://stackblitz.com/github/wevm/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('wevm.eth'), }) // '0xd2135CfB216b74109775236E36d4b433F1DF507B'
client.getEnsAvatar (args: { assetGatewayUrls?: AssetGatewayUrls ; blockNumber?: bigint ; blockTag?: BlockTag ; gatewayUrls?: string[] ; name: string ; strict?: boolean ; universalResolverAddress?: `0x${string}` }) => Promise<GetEnsAvatarReturnType> Gets the avatar of an ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsAvatar - Examples: https://stackblitz.com/github/wevm/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('wevm.eth'), }) // 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'
client.getEnsName (args: { address: `0x${string}` ; blockNumber?: bigint ; blockTag?: BlockTag ; gatewayUrls?: string[] ; strict?: boolean ; universalResolverAddress?: `0x${string}` }) => Promise<GetEnsNameReturnType> Gets primary name for specified address. - Docs: https://viem.sh/docs/ens/actions/getEnsName - Examples: https://stackblitz.com/github/wevm/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', }) // 'wevm.eth'
client.getEnsResolver (args: { blockNumber?: bigint ; blockTag?: BlockTag ; name: string ; universalResolverAddress?: `0x${string}` }) => Promise<`0x${string}`> Gets resolver for ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsResolver - Examples: https://stackblitz.com/github/wevm/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('wevm.eth'), }) // '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
client.getEnsText (args: { blockNumber?: bigint ; blockTag?: BlockTag ; gatewayUrls?: string[] ; key: string ; name: string ; strict?: boolean ; universalResolverAddress?: `0x${string}` }) => Promise<GetEnsTextReturnType> Gets a text record for specified ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsResolver - Examples: https://stackblitz.com/github/wevm/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('wevm.eth'), key: 'com.twitter', }) // 'wagmi_sh'
client.getFeeHistory (args: GetFeeHistoryParameters) => Promise<GetFeeHistoryReturnType> Returns a collection of historical gas information. - Docs: https://viem.sh/docs/actions/public/getFeeHistory - 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], })
client.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 - 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 })
client.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 - 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 })
client.getGasPrice () => Promise<bigint> Returns the current price of gas (in wei). - Docs: https://viem.sh/docs/actions/public/getGasPrice - 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()
client.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 - Examples: https://stackblitz.com/github/wevm/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()
client.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 - 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...'], })
client.getStorageAt (args: GetStorageAtParameters) => Promise<GetStorageAtReturnType> Returns the value from a storage slot at a given address. - Docs: https://viem.sh/docs/contract/getStorageAt - 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), })
client.getTransaction <TBlockTag>(args: GetTransactionParameters<TBlockTag>) => Promise<{ accessList?: undefined ; blobVersionedHashes?: undefined ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "legacy" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity?: undefined } | { accessList: AccessList ; blobVersionedHashes?: undefined ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "eip2930" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity: number } | { accessList: AccessList ; blobVersionedHashes?: undefined ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "eip1559" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity: number } | { accessList: AccessList ; blobVersionedHashes: `0x${string}`[] ; blockHash: TBlockTag extends "pending" ? true : false extends true ? null : `0x${string}` ; blockNumber: TBlockTag 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: null | `0x${string}` ; transactionIndex: TBlockTag extends "pending" ? true : false extends true ? null : number ; type: "eip4844" ; typeHex: null | `0x${string}` ; v: bigint ; value: bigint ; yParity: number }> Returns information about a Transaction given a hash or block identifier. - Docs: https://viem.sh/docs/actions/public/getTransaction - Example: https://stackblitz.com/github/wevm/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', })
client.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 - Example: https://stackblitz.com/github/wevm/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', })
client.getTransactionCount (args: GetTransactionCountParameters) => Promise<number> Returns the number of Transactions an Account has broadcast / sent. - Docs: https://viem.sh/docs/actions/public/getTransactionCount - 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', })
client.getTransactionReceipt (args: GetTransactionReceiptParameters) => Promise<TransactionReceipt> Returns the Transaction Receipt given a Transaction hash. - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt - Example: https://stackblitz.com/github/wevm/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', })
client.key string A key for the client.
client.multicall <contracts, allowFailure>(args: MulticallParameters<contracts, allowFailure>) => Promise<MulticallReturnType<contracts, allowFailure>> 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 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' }]
client.name string A name for the client.
client.pollingInterval number Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
client.prepareTransactionRequest <TRequest, TChainOverride, TAccountOverride>(args: PrepareTransactionRequestParameters<undefined | Chain, undefined | Account, TChainOverride, TAccountOverride, TRequest>) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(…), (…)> & ((…) extends (…) ? (…) : (…)) & ((…) extends (…) ? (…) : (…)), IsNever<(…)> extends true ? unknown : ExactPartial<(…)>> & Object, ParameterTypeToParameters<TRequest[“parameters”] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : “type” | “gas” | “nonce” | “blobVersionedHashes” | “chainId” | “fees”>> & (unknown extends TRequest[“kzg”] ? Object : Pick<TRequest, “kzg”>))[K] }> Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest 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, })
client.readContract <abi, functionName, args>(args: ReadContractParameters<abi, functionName, args>) => Promise<ReadContractReturnType<abi, functionName, args>> Calls a read-only function on a contract, and returns the response. - Docs: https://viem.sh/docs/contract/readContract - Examples: https://stackblitz.com/github/wevm/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
client.request EIP1193RequestFn<PublicRpcSchema> Request function wrapped with friendly error handling
client.sendRawTransaction (args: SendRawTransactionParameters) => Promise<`0x${string}`> Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - 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' })
client.simulateContract <abi, functionName, args, chainOverride, accountOverride>(args: SimulateContractParameters<abi, functionName, args, undefined | Chain, chainOverride, accountOverride>) => Promise<SimulateContractReturnType<abi, functionName, args, undefined | Chain, undefined | Account, chainOverride, accountOverride>> 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 - Examples: https://stackblitz.com/github/wevm/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', })
client.transport TransportConfig<string, EIP1193RequestFn> & Record<string, any> The RPC transport
client.type string The type of client.
client.uid string A unique ID for the client.
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 - 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
client.verifyMessage (args: VerifyMessageParameters) => Promise<boolean> -
client.verifyTypedData (args: VerifyTypedDataParameters) => Promise<boolean> -
client.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 - Example: https://stackblitz.com/github/wevm/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', })
client.watchBlockNumber (args: WatchBlockNumberParameters) => WatchBlockNumberReturnType Watches and returns incoming block numbers. - Docs: https://viem.sh/docs/actions/public/watchBlockNumber - Examples: https://stackblitz.com/github/wevm/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), })
client.watchBlocks <TIncludeTransactions, TBlockTag>(args: WatchBlocksParameters<Transport, undefined | Chain, TIncludeTransactions, TBlockTag>) => WatchBlocksReturnType Watches and returns information for incoming blocks. - Docs: https://viem.sh/docs/actions/public/watchBlocks - Examples: https://stackblitz.com/github/wevm/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), })
client.watchContractEvent <TAbi, TEventName, TStrict>(args: WatchContractEventParameters<TAbi, TEventName, TStrict, Transport>) => WatchContractEventReturnType Watches and returns emitted contract event logs. - Docs: https://viem.sh/docs/contract/watchContractEvent 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), })
client.watchEvent <TAbiEvent, TAbiEvents, TStrict>(args: WatchEventParameters<TAbiEvent, TAbiEvents, TStrict, Transport>) => WatchEventReturnType Watches and returns emitted Event Logs. - Docs: https://viem.sh/docs/actions/public/watchEvent - 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), })
client.watchPendingTransactions (args: WatchPendingTransactionsParameters<Transport>) => WatchPendingTransactionsReturnType Watches and returns pending transaction hashes. - Docs: https://viem.sh/docs/actions/public/watchPendingTransactions - 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), })

Returns

Promise<boolean>

true if the contract exists and false otherwise

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:213


createKernelClient

createKernelClient(signer, chainId, zeroDevProjectId): Promise<KernelAccountClient<"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", Transport, Chain, any>>

It creates a ZeroDev Kernel client.

Parameters

Name Type Description
signer any the signer account
chainId number the chain id
zeroDevProjectId string the zero dev project id, you can get it from the ZeroDev dashboard

Returns

Promise<KernelAccountClient<"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", Transport, Chain, any>>

the kernel client

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:533


createSessionKey

createSessionKey(signer, publicClient, permissions): Promise<string>

It creates a ZeroDev Session Key with some specific permissions

Parameters

Name Type Description
signer any the signer account
publicClient any the blockchain client
permissions any[] the permissions to configure in the session key

Returns

Promise<string>

the session key serialized

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:581


decryptMessage

decryptMessage(encryptedMessage, privateKey): Promise<string>

Parameters

Name Type
encryptedMessage string
privateKey any

Returns

Promise<string>

Defined in

src/common/helpers.ts:81


deployContractInstance

deployContractInstance(artifact, from, args?, client): Promise<{ abi: Abi ; address: `0x${string}` ; createEventFilter: {} ; estimateGas: {} & {} ; getEvents: {} ; read: {} ; simulate: {} ; watchEvent: {} ; write: {} }>

Given an artifact, it deploys the contract and returns the contract instance.

Parameters

Name Type Default value Description
artifact Object undefined the contract artifact
artifact.abi Abi undefined -
artifact.bytecode `0x${string}` undefined -
artifact.name? string undefined -
from NvmAccount undefined the deployer account
args string[] [] parameters to be passed to the contract during the initialization
client Web3Clients undefined the client to interact with the blockchain

Returns

Promise<{ abi: Abi ; address: `0x${string}` ; createEventFilter: {} ; estimateGas: {} & {} ; getEvents: {} ; read: {} ; simulate: {} ; watchEvent: {} ; write: {} }>

a contract instance

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:150


deserializeECIES

deserializeECIES(serialized): Object

Parameters

Name Type
serialized any

Returns

Object

Name Type
ciphertext Buffer
ephemPublicKey Buffer
iv Buffer
mac Buffer

Defined in

src/common/helpers.ts:99


didPrefixed

didPrefixed(input): string

Parameters

Name Type
input string

Returns

string

Defined in

src/utils/ConversionTypeHelpers.ts:13


didToTokenId

didToTokenId(did): bigint

It converts a DID to a Token ID. This is useful because in the Solidity Smart contracts the tokenId is a uint256.

Parameters

Name Type Description
did string the unique identifier of the asset

Returns

bigint

the token id in a bigint format

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:320


didTransformer

didTransformer(input?, prefixOutput): string

Parameters

Name Type Default value
input string ''
prefixOutput boolean undefined

Returns

string

Defined in

src/utils/ConversionTypeHelpers.ts:16


didZeroX

didZeroX(input): `0x${string}`

Parameters

Name Type
input string

Returns

`0x${string}`

Defined in

src/utils/ConversionTypeHelpers.ts:22


encodeBytes32String

encodeBytes32String(message): `0x${string}`

Encodes a UTF-8 string into a hex string

Parameters

Name Type Description
message string the string to encode

Returns

`0x${string}`

the hex string

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:367


encryptMessage

encryptMessage(message, receiverPublicKey): Promise<string>

Parameters

Name Type
message string
receiverPublicKey string

Returns

Promise<string>

Defined in

src/common/helpers.ts:74


eventToObject

eventToObject(event): any

Parameters

Name Type
event any

Returns

any

Defined in

src/utils/Events.ts:1


formatEther

formatEther(value): string

Converts a wei value into ether.

Parameters

Name Type Description
value bigint The value to format.

Returns

string

The string of the formatted value

Example

const value = 1000000000000000000n

formatEther(value)
// '1.0'

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:520


formatUnits

formatUnits(value, decimals?): string

Returns a string representation of value formatted with decimal digits.

Parameters

Name Type Default value Description
value bigint undefined The value to format.
decimals number 18 -

Returns

string

The string of the formatted value

Example

const oneEther = 1000000000000000000n

formatUnits(oneEther, 18)
// '1.0'

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:483


generateId

generateId(length?): string

Parameters

Name Type Default value
length number 64

Returns

string

Defined in

src/common/helpers.ts:39


generateInstantiableConfigFromConfig

generateInstantiableConfigFromConfig(config, loadCore?): Promise<Partial<InstantiableConfig>>

Parameters

Name Type Default value
config NeverminedOptions undefined
loadCore boolean true

Returns

Promise<Partial<InstantiableConfig>>

Defined in

src/Instantiable.abstract.ts:30


getBurnNFTPermissions

getBurnNFTPermissions(nftContractAddress): { abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "_3" ; type: "uint256" }] ; name: "burn" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘burn’; target: `0x${string}` = nftContractAddress }[]

Parameters

Name Type
nftContractAddress `0x${string}`

Returns

{ abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "_3" ; type: "uint256" }] ; name: "burn" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘burn’; target: `0x${string}` = nftContractAddress }[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:54


getBytes

getBytes(message): Uint8Array

Encodes a UTF-8 string into a byte array.

Parameters

Name Type Description
message string the string to encode

Returns

Uint8Array

the encoded byte array

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:348


getChain

getChain(networkId): Chain

Parameters

Name Type
networkId undefined | number

Returns

Chain

Defined in

src/utils/Network.ts:152


getChecksumAddress

getChecksumAddress(address): string

Given an address it returns that address in checksum format.

Parameters

Name Type Description
address string the address

Returns

string

the same address in checksum format

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:329


getCircularReplacer

getCircularReplacer(): (_key: any, value: any) => any

Returns

fn

▸ (_key, value): any

Parameters
Name Type
_key any
value any
Returns

any

Defined in

src/common/helpers.ts:21


getConditionsByParams

getConditionsByParams(serviceType, conditions, owner, assetPrice?, did?, erc20TokenContract?, nftTokenContract?, nftHolder?, nftAmount?, nftTransfer?, duration?, fulfillAccessTimeout?, fulfillAccessTimelock?, tokenId?): ServiceAgreementTemplateCondition[]

Fill some static parameters that depends on the metadata.

Parameters

Name Type Default value Description
serviceType ServiceType undefined The type of the service “access”, “nft-sales”, etc.
conditions readonly ServiceAgreementTemplateCondition[] undefined List of conditions to fill.
owner string undefined Owner of the asset.
assetPrice AssetPrice undefined Rewards distribution
did? string undefined The DID of the asset.
erc20TokenContract? string undefined The address of the ERC20 token contract used for payment (0x0 address if native token).
nftTokenContract? string undefined The address of the NFT token contract used.
nftHolder? string undefined The address of the NFT holder.
nftAmount bigint undefined Number of nfts to handle
nftTransfer boolean false If the nft will be transferred (true) or minted (false)
duration number 0 Duration if it’s a subscription
fulfillAccessTimeout number 0 Timeout for the fulfill of the access service
fulfillAccessTimelock number 0 Timelock for the fulfill of the access service
tokenId string '' The token id of the NFT

Returns

ServiceAgreementTemplateCondition[]

Filled conditions.

Defined in

src/ddo/DDO.ts:61


getContractInstance

getContractInstance(contractAddress, abi, client): Promise<{ abi: Abi ; address: `0x${string}` ; createEventFilter: {} ; estimateGas: {} & {} ; getEvents: {} ; read: {} ; simulate: {} ; watchEvent: {} ; write: {} }>

Given an already deployed contract address and the ABI, it returns the contract instance.

Parameters

Name Type Description
contractAddress string the contract address
abi Abi the contract artifact
client Web3Clients the client to interact with the blockchain

Returns

Promise<{ abi: Abi ; address: `0x${string}` ; createEventFilter: {} ; estimateGas: {} & {} ; getEvents: {} ; read: {} ; simulate: {} ; watchEvent: {} ; write: {} }>

a contract instance

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:199


getERC20ApprovePermissions

getERC20ApprovePermissions(contractAddress): { abi: readonly [{ inputs: readonly [{ name: "spender" ; type: "address" }, { name: "amount" ; type: "uint256" }] ; name: "approve" ; outputs: readonly [{ type: "bool" }] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘approve’; target: `0x${string}` = contractAddress }[]

Parameters

Name Type
contractAddress `0x${string}`

Returns

{ abi: readonly [{ inputs: readonly [{ name: "spender" ; type: "address" }, { name: "amount" ; type: "uint256" }] ; name: "approve" ; outputs: readonly [{ type: "bool" }] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘approve’; target: `0x${string}` = contractAddress }[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:34


getERC20TransferPermissions

getERC20TransferPermissions(contractAddress): { abi: readonly [{ inputs: readonly [{ name: "to" ; type: "address" }, { name: "amount" ; type: "uint256" }] ; name: "transfer" ; outputs: readonly [{ type: "bool" }] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘transfer’; target: `0x${string}` = contractAddress }[]

Parameters

Name Type
contractAddress `0x${string}`

Returns

{ abi: readonly [{ inputs: readonly [{ name: "to" ; type: "address" }, { name: "amount" ; type: "uint256" }] ; name: "transfer" ; outputs: readonly [{ type: "bool" }] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘transfer’; target: `0x${string}` = contractAddress }[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:44


getFullZeroDevPermissions

getFullZeroDevPermissions(didRegistryAddress, salesTemplateAddress, erc20Address, nft1155CreditsAddress, nft1155TimeAddress): ({ abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_mint" ; type: "bool" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_id" ; type: "bytes32" }, { name: "_did" ; type: "bytes32" }, { name: "_conditionIds" ; type: "bytes32[]" }, { name: "_timeLocks" ; type: "uint256[]" }, { name: "_timeOuts" ; type: "uint256[]" }, { name: "_accessConsumer" ; type: "address" }, { name: "_idx" ; type: "uint256" }, { name: "_rewardAddress" ; type: "address" }, { name: "_tokenAddress" ; type: "address" }, { name: "_amounts" ; type: "uint256[]" }, { name: "_receivers" ; type: "address[]" }] ; name: "createAgreementAndPayEscrow" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘createAgreementAndPayEscrow’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "spender" ; type: "address" }, { name: "amount" ; type: "uint256" }] ; name: "approve" ; outputs: readonly [{ type: "bool" }] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘approve’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "_3" ; type: "uint256" }] ; name: "burn" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘burn’; target: `0x${string}` = nftContractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "amount_3" ; type: "uint256" }, { name: "_4" ; type: "bytes" }] ; name: "mint" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘mint’; target: `0x${string}` = nftContractAddress })[]

Parameters

Name Type
didRegistryAddress `0x${string}`
salesTemplateAddress `0x${string}`
erc20Address `0x${string}`
nft1155CreditsAddress `0x${string}`
nft1155TimeAddress `0x${string}`

Returns

({ abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_mint" ; type: "bool" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_id" ; type: "bytes32" }, { name: "_did" ; type: "bytes32" }, { name: "_conditionIds" ; type: "bytes32[]" }, { name: "_timeLocks" ; type: "uint256[]" }, { name: "_timeOuts" ; type: "uint256[]" }, { name: "_accessConsumer" ; type: "address" }, { name: "_idx" ; type: "uint256" }, { name: "_rewardAddress" ; type: "address" }, { name: "_tokenAddress" ; type: "address" }, { name: "_amounts" ; type: "uint256[]" }, { name: "_receivers" ; type: "address[]" }] ; name: "createAgreementAndPayEscrow" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘createAgreementAndPayEscrow’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "spender" ; type: "address" }, { name: "amount" ; type: "uint256" }] ; name: "approve" ; outputs: readonly [{ type: "bool" }] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘approve’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "_3" ; type: "uint256" }] ; name: "burn" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘burn’; target: `0x${string}` = nftContractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "amount_3" ; type: "uint256" }, { name: "_4" ; type: "bytes" }] ; name: "mint" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘mint’; target: `0x${string}` = nftContractAddress })[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:74


getInputsOfFunction

getInputsOfFunction(abi, funcName, args?): readonly AbiParameter[]

It searchs an ABI function in the ABI and return the inputs.

Parameters

Name Type Default value Description
abi Abi undefined the ABI of the contract
funcName string undefined the function name
args any[] [] the args of the function

Returns

readonly AbiParameter[]

the function found

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:292


getInputsOfFunctionFormatted

getInputsOfFunctionFormatted(abi, funcName, args?): { name: undefined | string = input.name; value: any }[]

It searchs an ABI function in the ABI and return the inputs formatted.

Parameters

Name Type Default value Description
abi Abi undefined the ABI of the contract
funcName string undefined the function name
args any[] [] the args of the function

Returns

{ name: undefined | string = input.name; value: any }[]

the function found

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:303


getMintNFTPermissions

getMintNFTPermissions(nftContractAddress): { abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "amount_3" ; type: "uint256" }, { name: "_4" ; type: "bytes" }] ; name: "mint" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘mint’; target: `0x${string}` = nftContractAddress }[]

Parameters

Name Type
nftContractAddress `0x${string}`

Returns

{ abi: readonly [{ inputs: readonly [{ name: "_1" ; type: "address" }, { name: "_2" ; type: "uint256" }, { name: "amount_3" ; type: "uint256" }, { name: "_4" ; type: "bytes" }] ; name: "mint" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘mint’; target: `0x${string}` = nftContractAddress }[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:64


getNetworkName

getNetworkName(networkId): Promise<string>

Parameters

Name Type
networkId number

Returns

Promise<string>

Defined in

src/utils/Network.ts:19


getOrderPermissions

getOrderPermissions(contractAddress): { abi: readonly [{ inputs: readonly [{ name: "_id" ; type: "bytes32" }, { name: "_did" ; type: "bytes32" }, { name: "_conditionIds" ; type: "bytes32[]" }, { name: "_timeLocks" ; type: "uint256[]" }, { name: "_timeOuts" ; type: "uint256[]" }, { name: "_accessConsumer" ; type: "address" }, { name: "_idx" ; type: "uint256" }, { name: "_rewardAddress" ; type: "address" }, { name: "_tokenAddress" ; type: "address" }, { name: "_amounts" ; type: "uint256[]" }, { name: "_receivers" ; type: "address[]" }] ; name: "createAgreementAndPayEscrow" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘createAgreementAndPayEscrow’; target: `0x${string}` = contractAddress }[]

Parameters

Name Type
contractAddress `0x${string}`

Returns

{ abi: readonly [{ inputs: readonly [{ name: "_id" ; type: "bytes32" }, { name: "_did" ; type: "bytes32" }, { name: "_conditionIds" ; type: "bytes32[]" }, { name: "_timeLocks" ; type: "uint256[]" }, { name: "_timeOuts" ; type: "uint256[]" }, { name: "_accessConsumer" ; type: "address" }, { name: "_idx" ; type: "uint256" }, { name: "_rewardAddress" ; type: "address" }, { name: "_tokenAddress" ; type: "address" }, { name: "_amounts" ; type: "uint256[]" }, { name: "_receivers" ; type: "address[]" }] ; name: "createAgreementAndPayEscrow" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘createAgreementAndPayEscrow’; target: `0x${string}` = contractAddress }[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:22


getRegisterAssetPermissions

getRegisterAssetPermissions(contractAddress): ({ abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_mint" ; type: "bool" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress })[]

Parameters

Name Type
contractAddress `0x${string}`

Returns

({ abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_mint" ; type: "bool" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress } | { abi: readonly [{ inputs: readonly [{ name: "_didSeed" ; type: "bytes32" }, { name: "_nftContractAddress" ; type: "address" }, { name: "_checksum" ; type: "bytes32" }, { name: "_providers" ; type: "address[]" }, { name: "_url" ; type: "string" }, { name: "_cap" ; type: "uint256" }, { name: "_royalties" ; type: "uint256" }, { name: "_activityId" ; type: "bytes32" }, { name: "_nftMetadata" ; type: "string" }, { name: "_immutableUrl" ; type: "string" }] ; name: "registerMintableDID" ; outputs: readonly [] ; stateMutability: "nonpayable" ; type: "function" }] ; functionName: string = ‘registerMintableDID’; target: `0x${string}` = contractAddress })[]

Defined in

src/nevermined/resources/ZeroDevPermissions.ts:3


getRoyaltyAttributes

getRoyaltyAttributes(nvm, kind, amount): RoyaltyAttributes

It gets a RoyaltyAttributes instance

Parameters

Name Type Description
nvm Nevermined Nevermined instance
kind RoyaltyKind The type of royalty
amount number The amount of royalties to get in the secondary market

Returns

RoyaltyAttributes

The RoyaltyAttributes instance

Defined in

src/nevermined/api/AssetsApi.ts:62


getRoyaltyScheme

getRoyaltyScheme(nvm, kind): RoyaltyScheme | undefined

It gets the on-chain royalties scheme

Parameters

Name Type Description
nvm Nevermined Nevermined instance
kind RoyaltyKind The type of royalty

Returns

RoyaltyScheme | undefined

The royalty scheme

Defined in

src/nevermined/api/AssetsApi.ts:47


getSessionKey

getSessionKey(serializedSessionKey, zeroDevProjectId, publicClient): Promise<NvmAccount>

Given a serialized session key it reconstructs the NvmAccount represented by the session key.

Parameters

Name Type Description
serializedSessionKey string the serialized session key
zeroDevProjectId string the zero dev project id
publicClient any the blockchain client

Returns

Promise<NvmAccount>

the NvmAccount represented by the session key

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:616


getSignatureOfFunction

getSignatureOfFunction(abi, funcName, args?): AbiFunction

It searchs an ABI function in the ABI.

Parameters

Name Type Default value Description
abi Abi undefined the ABI of the contract
funcName string undefined the function name
args any[] [] the args of the function

Returns

AbiFunction

the function found

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:281


getWeb3ViemClients

getWeb3ViemClients(config?): Promise<Web3Clients>

Parameters

Name Type
config Partial<NeverminedOptions>

Returns

Promise<Web3Clients>

Defined in

src/Instantiable.abstract.ts:50


isTestnet

isTestnet(networkId): boolean

Parameters

Name Type
networkId number

Returns

boolean

Defined in

src/utils/Network.ts:85


isValidAddress

isValidAddress(address): boolean

It checks if the address is a valid address.

Parameters

Name Type Description
address string the address to check

Returns

boolean

true of the address is valid

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:338


isWindowEthereumDefined

isWindowEthereumDefined(): boolean

Returns

boolean

Defined in

src/nevermined/resources/AppNetworks.ts:189


jsonReplacer

jsonReplacer(_key, value): any

Parameters

Name Type
_key any
value any

Returns

any

Defined in

src/common/helpers.ts:34


keccak256

keccak256(seed): string

It hashes a string using keccak256.

Parameters

Name Type Description
seed string the string to hash

Returns

string

the hash

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:422


keccak256Packed

keccak256Packed(types, values): string

It encodes and hashes a list of primitive values into an ABI-encoded hex value.

Parameters

Name Type Description
types any[] the types of the values
values any[] the values to encode

Returns

string

the hash

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:443


keccak256WithEncode

keccak256WithEncode(types, values): string

It encodes and hashes a list of primitive values into an ABI-encoded hex value.

Parameters

Name Type Description
types any[] the types of the values
values any[] the values to encode

Returns

string

the hash

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:432


makeRandomWallet

makeRandomWallet(): HDAccount

It generates a random account.

Returns

HDAccount

a new account

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:400


makeRandomWallets

makeRandomWallets(numAccounts?): any[]

It generates a list of random accounts

Parameters

Name Type Default value Description
numAccounts number 10 the number of accounts to create

Returns

any[]

the array of accounts

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:410


makeWallet

makeWallet(seedphrase, addressIndex?): HDAccount

Given a seedphrase, it returns an account.

Parameters

Name Type Default value Description
seedphrase string undefined the seedphrase to be used to generate the account
addressIndex number 0 the address index

Returns

HDAccount

an account

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:378


makeWallets

makeWallets(seedphrase, numAccounts?): any[]

Given a seedphrase generates multiple accounts

Parameters

Name Type Default value Description
seedphrase string undefined the seedphrase to be used to generate the account
numAccounts number 10 the number of accounts to create

Returns

any[]

the array of accounts

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:388


noDidPrefixed

noDidPrefixed(input): string

Parameters

Name Type
input string

Returns

string

Defined in

src/utils/ConversionTypeHelpers.ts:14


noZeroX

noZeroX(input): string

Parameters

Name Type
input string

Returns

string

Defined in

src/utils/ConversionTypeHelpers.ts:5


objectPromiseAll

objectPromiseAll(obj): Promise<{}>

Parameters

Name Type
obj Object

Returns

Promise<{}>

Defined in

src/utils/PromiseResolver.ts:11


parseEther

parseEther(value): bigint

Converts a ether value into wei.

Parameters

Name Type Description
value string The string value to convert

Returns

bigint

The BigInt representation of value in wei

Example

parseEther('1.0')
// 1000000000000000000n

parseEther('-0.5')
// -500000000000000000n

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:502


parseUnits

parseUnits(value, decimals?): bigint

Returns a BigInt representation of value, parsed with decimal digits.

Parameters

Name Type Default value Description
value string undefined The string value to convert
decimals number 18 The number of decimals

Returns

bigint

The BigInt representation of value parsed with decimals

Example

parseUnits('1.0', 18)
// 1000000000000000000n

parseUnits('121.0', 9)
// 121000000000n

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:465


searchAbiEvent

searchAbiEvent(abi, eventName): AbiEvent

It searchs an ABI event in the ABI.

Parameters

Name Type Description
abi Abi the ABI of the contract
eventName string -

Returns

AbiEvent

the event found

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:263


searchAbiFunction

searchAbiFunction(abi, funcName, args?): AbiFunction

It searchs an ABI function in the ABI.

Parameters

Name Type Default value Description
abi Abi undefined the ABI of the contract
funcName string undefined the function name
args any[] [] the args of the function

Returns

AbiFunction

the function found

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:245


serializeECIES

serializeECIES(ecies): string

Parameters

Name Type
ecies any

Returns

string

Defined in

src/common/helpers.ts:88


urlSafeBase64Decode

urlSafeBase64Decode(input): Uint8Array

Parameters

Name Type
input string

Returns

Uint8Array

Defined in

src/common/helpers.ts:60


urlSafeBase64Encode

urlSafeBase64Encode(input): string

Parameters

Name Type
input Uint8Array

Returns

string

Defined in

src/common/helpers.ts:51


zeroPadValue

zeroPadValue(value, length): string

It pads a value with zeros.

Parameters

Name Type Description
value `0x${string}` | Uint8Array the value to pad
length number the expected longitutde of the value

Returns

string

the padded value

Defined in

src/nevermined/utils/BlockchainViemUtils.ts:358


zeroX

zeroX(input): `0x${string}`

Parameters

Name Type
input string

Returns

`0x${string}`

Defined in

src/utils/ConversionTypeHelpers.ts:4


zeroXTransformer

zeroXTransformer(input?, zeroOutput): string

Parameters

Name Type Default value
input string ''
zeroOutput boolean undefined

Returns

string

Defined in

src/utils/ConversionTypeHelpers.ts:7