Voltaire effect provider

From cyotee/indexedex · View interactive version

Voltaire effect provider is an AI agent skill from the GitHub repository cyotee/indexedex. JSON-RPC provider operations with Effect.ts. Use when reading blockchain data, making contract calls, or estimating gas.

How to use this skill

Skill file

Provider Service

JSON-RPC operations with Effect.ts composition.

Setup

import { Effect, Layer } from 'effect'
import { Provider, HttpTransport } from 'voltaire-effect'

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

Block Operations

import { getBlockNumber, getBlock, getBlockReceipts } from 'voltaire-effect'

const program = Effect.gen(function* () {
  const blockNum = yield* getBlockNumber()
  const block = yield* getBlock({ blockTag: 'latest', includeTransactions: true })
  const receipts = yield* getBlockReceipts({ blockTag: 'latest' })
  return { blockNum, block, receipts }
})

Account State

import { getBalance, getTransactionCount, getCode, getStorageAt } from 'voltaire-effect'

const state = yield* Effect.all({
  balance: getBalance('0x123...', 'latest'),
  nonce: getTransactionCount('0x123...'),
  code: getCode('0x123...'),
  slot: getStorageAt('0x123...', '0x0')
})

Read Contract

import { readContract } from 'voltaire-effect'

const erc20Abi = [
  { type: 'function', name: 'balanceOf', stateMutability: 'view',
    inputs: [{ name: 'account', type: 'address' }],
    outputs: [{ name: 'balance', type: 'uint256' }]
  }
] as const

const balance = yield* readContract({
  address: '0x6B175474E89094C44Da98b954EecdEfaE6E286AB',
  abi: erc20Abi,
  functionName: 'balanceOf',
  args: ['0x1234567890123456789012345678901234567890']
})

Multicall

import { multicall } from 'voltaire-effect'

const results = yield* multicall({
  contracts: [
    { address: tokenA, abi: erc20Abi, functionName: 'balanceOf', args: [user] },
    { address: tokenB, abi: erc20Abi, functionName: 'balanceOf', args: [user] }
  ]
})
// results: [{ status: 'success', result: 1000n }, { status: 'success', result: 500n }]

Timeout & Retry

import { withTimeout, withRetrySchedule } from 'voltaire-effect'
import { Schedule } from 'effect'

const balance = yield* getBalance(addr).pipe(
  withTimeout('5 seconds'),
  withRetrySchedule(Schedule.exponential('500 millis').pipe(
    Schedule.jittered,
    Schedule.compose(Schedule.recurs(3))
  ))
)

Simulate Contract

import { simulateContract } from 'voltaire-effect'

const { result, request } = yield* simulateContract({
  address: tokenAddress,
  abi: erc20Abi,
  functionName: 'transfer',
  args: [recipient, amount],
  account: senderAddress
})

Event Logs

import { getLogs } from 'voltaire-effect'

const logs = yield* getLogs({
  address: '0x123...',
  topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'],
  fromBlock: 18000000n,
  toBlock: 'latest'
})
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.