Skip to main content
Record provenance actions on-chain using createViemAdapter (server-side) or createEIP1193Adapter (browser wallets). Both implement IChainAdapter.

IChainAdapter Interface

Any object satisfying this interface works as a chain adapter — you can implement it directly for ethers.js, wagmi, or any other library.

createViemAdapter

For server-side or Node.js environments.

ViemAdapterOptions

createEIP1193Adapter

For browser environments with any EIP-1193 wallet.

EIP1193AdapterOptions

The EIP-1193 adapter uses a self-contained ABI encoder — no viem or ethers.js dependency. It calls:
  1. eth_call to simulate recordActionAndRegisterOutputs → get actionId bytes32
  2. eth_sendTransaction to broadcast with the same calldata

Using the Adapter with ProvenanceKit

Pass the adapter as chain when constructing ProvenanceKit:

On-Chain Recording Semantics

On-chain recording is fire-and-forget:
  • If the chain transaction succeeds → result.onchain is populated
  • If it fails (gas, RPC error, etc.) → result.onchain is undefined; the off-chain IPFS record still succeeds
This means blockchain availability cannot break your application. Check result.onchain to know if on-chain recording succeeded.

Custom IChainAdapter

Implement IChainAdapter directly for ethers.js or any other signing library:

Smart Wallet Session Keys (No Per-Action Popups)

For the best UX in browser apps: use Privy or Coinbase Smart Wallet session keys. The user approves the session once; all subsequent provenance calls are signed silently.

Gotchas

  • from address: The EIP-1193 adapter uses eth_accounts[0] as default sender. Override with from when using a smart wallet that differs from the EOA signer.
  • Chain switching: The adapter does not switch chains automatically. Ensure the provider is on the correct chain before calling pk.file().
  • Simulation first: createViemAdapter simulates before broadcasting (publicClient.simulateContract). If simulation fails, no gas is spent.
  • EIP-1193 and eth_call: The self-contained encoder encodes function calls without external ABI libraries. The function selector for recordActionAndRegisterOutputs is 0xd57e4f08.