Skip to main content

Services

Service Imports

import {
  // Provider
  ProviderService, Provider,
  getBlockNumber, getBalance, call, estimateGas,
  readContract, multicall, simulateContract,
  RawProviderService, RawProviderTransport,
  DebugService, Debug,
  EngineApiService, EngineApi,

  // Signer and account
  SignerService, Signer,
  AccountService, LocalAccount, JsonRpcAccount,

  // Transport
  TransportService, HttpTransport, WebSocketTransport, BrowserTransport,

  // Contract
  Contract,

  // Streaming
  makeBlockStream, BlockStreamService, BlockStream,
  makeTransactionStream, TransactionStreamService, TransactionStream,

  // Errors
  TransportError,
  ProviderResponseError, ProviderNotFoundError, ProviderValidationError,
  ProviderTimeoutError, ProviderStreamError,
  ProviderReceiptPendingError, ProviderConfirmationsPendingError,
  GetBalanceError, GetBlockError, WaitForTransactionReceiptError,
  SignerError, ContractCallError, ContractWriteError
} from 'voltaire-effect/services'
import { MnemonicAccount } from 'voltaire-effect/native'

Primitives

Import as namespaces:
import * as Address from 'voltaire-effect/primitives/Address'
import * as Hash from 'voltaire-effect/primitives/Hash'
import * as Hex from 'voltaire-effect/primitives/Hex'
import * as Bytes from 'voltaire-effect/primitives/Bytes'
import * as Uint from 'voltaire-effect/primitives/Uint'
import * as U256 from 'voltaire-effect/primitives/U256'
import * as Signature from 'voltaire-effect/primitives/Signature'
import * as Transaction from 'voltaire-effect/primitives/Transaction'
import * as Block from 'voltaire-effect/primitives/Block'
import * as Abi from 'voltaire-effect/primitives/Abi'

Common Schemas

PrimitiveSchemaDescription
AddressAddress.Hex20-byte address from hex
AddressAddress.ChecksummedEIP-55 checksummed (requires KeccakService)
HashHash.Hex32-byte hash from hex
HexHex.StringHex string from bytes
UintUint.Uint256256-bit uint from bigint
UintUint.Uint256Hex256-bit uint from hex
See Primitives for full list.

Crypto

import {
  // Hash services
  KeccakService, KeccakLive, KeccakTest,
  Sha256Service, Sha256Live,
  
  // Signature services
  Secp256k1Service, Secp256k1Live, Secp256k1Test,
  Ed25519Service, Ed25519Live,
  Bls12381Service, Bls12381Live,
  
  // Key derivation
  HdWalletService, HdWalletLive,
  Bip39Service, Bip39Live,
  
  // Encryption
  AesGcmService, AesGcmLive,
  
  // Combined layers
  CryptoLive,  // All crypto services
  CryptoTest   // Mock layer for testing
} from 'voltaire-effect/crypto'
See Crypto for full list.

Standards

import * as ERC20 from 'voltaire-effect/standards/ERC20'
import * as ERC721 from 'voltaire-effect/standards/ERC721'
import * as ERC1155 from 'voltaire-effect/standards/ERC1155'
import * as ERC165 from 'voltaire-effect/standards/ERC165'
See ERC Standards for encoding/decoding utilities.

Effect Imports

import { Effect, Layer, Stream, Schedule, Duration, Exit, Cause } from 'effect'
import * as S from 'effect/Schema'
import * as Either from 'effect/Either'

Error Types

ErrorTagWhere
ParseErrorParseErrorSchema decode
SignerErrorSignerErrorSigner methods
TransportErrorTransportErrorTransport requests
ProviderResponseErrorProviderResponseErrorInvalid provider response
ProviderNotFoundErrorProviderNotFoundErrorMissing block/tx/receipt
ProviderValidationErrorProviderValidationErrorInvalid provider inputs
ProviderTimeoutErrorProviderTimeoutErrorProvider timeouts
ProviderStreamErrorProviderStreamErrorProvider stream failures
ProviderReceiptPendingErrorProviderReceiptPendingErrorReceipt not available yet
ProviderConfirmationsPendingErrorProviderConfirmationsPendingErrorConfirmations not met
ContractCallErrorContractCallErrorContract reads
ContractWriteErrorContractWriteErrorContract writes
CryptoErrorCryptoErrorCrypto operations
Provider methods expose method-specific error unions like GetBalanceError, GetBlockError, and WaitForTransactionReceiptError.

Layer Composition Patterns

Provider Layer

const ProviderLayer = Provider.pipe(
  Layer.provide(HttpTransport('https://eth.llamarpc.com'))
)

Signer with Local Account

// Compose dependencies first
const CryptoLayer = Layer.mergeAll(Secp256k1Live, KeccakLive)
const TransportLayer = HttpTransport('https://eth.llamarpc.com')
const DepsLayer = Layer.mergeAll(CryptoLayer, TransportLayer)

// Then provide composed layer
const SignerLayer = Signer.fromPrivateKey(privateKey, Provider).pipe(
  Layer.provide(DepsLayer)
)

Full Crypto Stack

const FullLayer = Layer.mergeAll(
  Provider,
  HttpTransport('https://eth.llamarpc.com'),
  CryptoLive
)

Running Effects

// Promise - throws on error
await Effect.runPromise(effect)

// Promise with Exit - captures errors
const exit = await Effect.runPromiseExit(effect)
Exit.match(exit, { onSuccess: ..., onFailure: ... })

// Sync - throws on async or error
Effect.runSync(effect)

// Sync Either - captures errors
const either = Effect.runSyncEither(effect)

See Also