/tokensdk

Client SDK for interacting with ERC-6551 accounts

Primary LanguageTypeScript

Tokenbound SDK

This repo houses the Tokenbound SDK, a front-end library for interacting with ERC-6551 accounts.

Packages

  • @tokenbound/sdk - SDK client for all projects, signing enabled via either Ethers Signer or viem WalletClient.
  • @tokenbound/react - Low-level react hooks for interacting with token bound accounts

Examples

Development

  1. Clone repository and install dependencies:
# clone the repo
$ git clone <repo>
# install dependencies
$ pnpm install
# build packages
$ pnpm --filter "@tokenbound/*" build

NOTE: Any local SDK changes require a rebuild to be useable in the example apps in /example

  1. Install Anvil to run a local Ethereum node.
  2. Configure environment variables. See .env.example for instructions
  3. Run dev server: pnpm dev

Unit/integration tests

Unit and integration tests are run by Vitest and rendered with a custom render function from React Testing Library. See usage of renderWithWagmiConfig in packages/sdk/src/tests.

This configuration allows us to use a single wagmi configuration to test the viem walletClient, Ethers 5, and Ethers 6 implementations with wagmi's Ethers adaptors

These tests require a local Anvil node so test transactions can be run against a mainnet fork.

Run Anvil

  1. Start Anvil in a terminal session
pnpm anvil
  1. Start Vitest in a different terminal session from the SDK root
pnpm test

Pre-commit Hooks

Husky has been configured to run a pre-commit hook to ensure tests pass

Thanks

Props to @tmm for sharing testing-wagmi for reference.