Skip to content

Evm.ts

This module handles EVM related functionality.

Added in v2.0.0

Signature

export declare class ChannelDestination

Added in v2.0.0

Source: src/Evm.ts:225

Signature

export declare class ChannelSource

Added in v2.0.0

Source: src/Evm.ts:239

A neutral public client that can be used for general-purpose operations that don’t specifically target source or destination chains

Signature

export declare class PublicClient

Added in v2.0.0

Source: src/Evm.ts:281

Signature

export declare class PublicClientDestination

Added in v2.0.0

Source: src/Evm.ts:265

Signature

export declare class PublicClientSource

Added in v2.0.0

Source: src/Evm.ts:254

A wallet client that can be used for signing transactions

Signature

export declare class WalletClient

Added in v2.0.0

Source: src/Evm.ts:294

Signature

export declare class CreatePublicClientError

Added in v2.0.0

Source: src/Evm.ts:321

Signature

export declare class CreateWalletClientError

Added in v2.0.0

Source: src/Evm.ts:331

Signature

export declare class ReadContractError

Added in v2.0.0

Source: src/Evm.ts:305

Signature

export declare class WaitForTransactionReceiptError

Added in v2.0.0

Source: src/Evm.ts:128

Signature

export declare class WriteContractError

Added in v2.0.0

Source: src/Evm.ts:313

Added in v2.0.0

Signature

export interface Channel {
readonly ucs03address: Address
readonly channelId: number
}

Source: src/Evm.ts:59

Added in v2.0.0

Signature

export interface PublicClient {
readonly client: ViemPublicClient
}

Source: src/Evm.ts:41

Added in v2.0.0

Signature

export interface WalletClient {
readonly client: ViemWalletClient
readonly account: ViemAccount
readonly chain: ViemChain
}

Source: src/Evm.ts:49

Added in v2.0.0

Signature

export declare const channelBalance: (
path: bigint,
token: Hex
) => Effect.Effect<bigint, ReadContractError, PublicClientDestination | ChannelDestination>

Source: src/Evm.ts:69

Added in v2.0.0

Signature

export declare const channelBalanceAtBlock: (
path: bigint,
token: Hex,
blockNumber: bigint
) => Effect.Effect<bigint, ReadContractError, PublicClientDestination | ChannelDestination>

Source: src/Evm.ts:88

Added in v2.0.0

Increase the allowance of an ERC20 token for a specific spender

Signature

export declare const increaseErc20Allowance: (
tokenAddress: Address,
spenderAddress: Address,
amount: bigint
) => Effect.Effect<`0x${string}`, WriteContractError, WalletClient>

Source: src/Evm.ts:550

Added in v2.0.0

Signature

export declare const predictQuoteToken: (
baseToken: Hex
) => Effect.Effect<`0x${string}`, ReadContractError, PublicClientDestination | ChannelDestination>

Source: src/Evm.ts:108

Added in v2.0.0

A type-safe wrapper around viem’s readContract that handles error cases and returns an Effect with proper type inference. Extracts all error info

Signature

export declare const readContract: <
TAbi extends Abi,
TFunctionName extends ContractFunctionName<TAbi, "pure" | "view"> = ContractFunctionName<TAbi, "view" | "pure">,
TArgs extends ContractFunctionArgs<TAbi, "pure" | "view", TFunctionName> = ContractFunctionArgs<
TAbi,
"view" | "pure",
TFunctionName
>
>(
client: ViemPublicClient,
params: ReadContractParameters<TAbi, TFunctionName, TArgs>
) => Effect.Effect<ContractFunctionReturnType<TAbi, "view" | "pure", TFunctionName, TArgs>, ReadContractError, never>

Source: src/Evm.ts:168

Added in v2.0.0

Read the allowance of an ERC20 token for a specific owner and spender

Signature

export declare const readErc20Allowance: (
tokenAddress: Address,
ownerAddress: Address,
spenderAddress: Address
) => Effect.Effect<bigint, ReadContractError, PublicClient>

Source: src/Evm.ts:524

Added in v2.0.0

Read the balance of an ERC20 token for a specific address

Signature

export declare const readErc20Balance: (
tokenAddress: Address,
ownerAddress: Address
) => Effect.Effect<bigint, ReadContractError, PublicClient>

Source: src/Evm.ts:378

Added in v2.0.0

Read the balance of an ERC20 token for a specific address

Signature

export declare const readErc20BalanceAtBlock: (
tokenAddress: Address,
ownerAddress: Address,
blockNumber: bigint
) => Effect.Effect<bigint, ReadContractError, PublicClient>

Source: src/Evm.ts:400

Added in v2.0.0

Read the decimals of an ERC20 token

Signature

export declare const readErc20Decimals: (
tokenAddress: Address
) => Effect.Effect<number, ReadContractError, PublicClient>

Source: src/Evm.ts:463

Added in v2.0.0

Read ERC20 token metadata (name, symbol, decimals)

Signature

export declare const readErc20Meta: (
tokenAddress: Address,
chainId: UniversalChainId
) => Effect.Effect<{ name: string; symbol: string; decimals: number }, ReadContractError, PublicClient>

Source: src/Evm.ts:346

Added in v2.0.0

Read the name of an ERC20 token

Signature

export declare const readErc20Name: (tokenAddress: Address) => Effect.Effect<string, ReadContractError, PublicClient>

Source: src/Evm.ts:425

Added in v2.0.0

Read the symbol of an ERC20 token

Signature

export declare const readErc20Symbol: (tokenAddress: Address) => Effect.Effect<string, ReadContractError, PublicClient>

Source: src/Evm.ts:444

Added in v2.0.0

Read the TotalSupply of an ERC20 token

Signature

export declare const readErc20TotalSupply: (
tokenAddress: Address
) => Effect.Effect<bigint, ReadContractError, PublicClient>

Source: src/Evm.ts:503

Added in v2.0.0

Read the TotalSupply of an ERC20 token

Signature

export declare const readErc20TotalSupplyAtBlock: (
tokenAddress: Address,
blockNumber: bigint
) => Effect.Effect<bigint, ReadContractError, PublicClient>

Source: src/Evm.ts:483

Added in v2.0.0

Signature

export declare const sendInstruction: (
instruction: Ucs03.Instruction
) => Effect.Effect<`0x${string}`, Utils.CryptoError | WriteContractError, WalletClient | ChannelSource>

Source: src/Evm.ts:572

Added in v2.0.0

Wait for a transaction receipt

Signature

export declare const waitForTransactionReceipt: (
hash: Hash
) => Effect.Effect<TransactionReceipt, WaitForTransactionReceiptError, PublicClient>

Source: src/Evm.ts:142

Added in v2.0.0

A type-safe wrapper around viem’s writeContract that handles error cases and returns an Effect with proper type inference. Extracts all error info

Signature

export declare const writeContract: <
TAbi extends Abi,
TFunctionName extends ContractFunctionName<TAbi, "nonpayable" | "payable"> = ContractFunctionName<
TAbi,
"nonpayable" | "payable"
>,
TArgs extends ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName> = ContractFunctionArgs<
TAbi,
"nonpayable" | "payable",
TFunctionName
>
>(
client: ViemWalletClient,
params: WriteContractParameters<TAbi, TFunctionName, TArgs>
) => Effect.Effect<`0x${string}`, WriteContractError, never>

Source: src/Evm.ts:200

Added in v2.0.0