@elacity-js/contracts-viem-adapter
v0.2.0
Published
Viem runner adapter for `@elacity-js/contracts`. Use this when you want to drive the Contracts SDK with Viem clients/wallets.
Readme
@elacity-js/contracts-viem-adapter
Viem runner adapter for @elacity-js/contracts. Use this when you want to drive the Contracts SDK with Viem clients/wallets.
Overview
This adapter implements the IContractRunner, IProvider, and IAbiEncoder interfaces from @elacity-js/contracts, allowing you to use Viem with the Elacity Contracts SDK.
Quick Start
import { ViemAdapter, ViemAbiEncoder } from '@elacity-js/contracts-viem-adapter';
import { StandardChannel } from '@elacity-js/contracts';
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
// Create adapter from viem wallet client
const account = privateKeyToAccount(privateKey);
const client = createWalletClient({ account, transport: http() });
const runner = new ViemAdapter(client);
const abiEncoder = new ViemAbiEncoder();
// Use with contract wrappers
const channel = new StandardChannel(channelAddress, runner);
const totalSupply = await channel.totalSupply();Exports
ViemAdapter: ImplementsIContractRunnerandIProviderfor executing contract calls, transactions, and fetching on-chain transaction data/receiptsViemAbiEncoder: ImplementsIAbiEncoderfor ABI encoding (used by media package)
Documentation
- https://docs.ela.city/sdks/contracts-viem-adapter/
Contributing
If you want to contribute:
- Keep changes focused on the
IContractRunner,IProvider, andIAbiEncoderimplementations inpackages/contracts-viem-adapter/src/lib/ - Add/update unit tests (
nx test contracts-viem-adapter) - Verify packaging (
nx build contracts-viem-adapter)
This library was generated with Nx.
Building
Run nx build contracts-viem-adapter to build the library.
Running unit tests
Run nx test contracts-viem-adapter to execute the unit tests via Jest.
