API Migration Guide

Core API changes when migrating from VeChain Kit 1.x to 2.0 with practical examples

Update Dependencies

First, update your package dependencies:

npm install @vechain/vechain-kit@^2.0.0
npm uninstall @thor-devkit

Clean install to avoid conflicts:

rm -rf node_modules package-lock.json
npm install

Update Imports

Update your import statements throughout your codebase:

// Before (1.x)
import { useConnex, useWallet, useTransaction } from '@vechain/vechain-kit';

// After (2.x)
import { useThor, useWallet, useBuildTransaction, useCallClause } from '@vechain/vechain-kit';

Note: For the complete list of removed hooks, see Removed Features

Connex to Thor

Basic Setup

v1:

v2:

Contract Interactions

Reading Contract Data

Single Contract Call

v1:

v2:

Multiple Contract Calls

v1:

v2:

Writing Contract Data (Transactions)

Simple Transaction

v1:

v2:

Multi-Clause Transaction

v1:

v2:

Transaction Building

Advanced Transaction Options

v1:

v2:

Events Handling

The events API has been redesigned in v2. See more.

v1:

v2:

Query Keys

Generating Query Keys

v2 introduces specific query key functions:

Custom Query Management

Migration Tips

  1. Start with Reading Operations: Migrate useCall to useCallClause first

  2. Update Transactions Incrementally: Convert one transaction type at a time

  3. Test Thoroughly: The new patterns handle edge cases differently

  4. Leverage Type Safety: Use TypeScript to catch migration issues

  5. Use Query Keys: Implement proper cache management with new query key functions

Last updated

Was this helpful?