General

Common issues and solutions during migration from 1.x to 2.0

TypeScript Compilation Errors

Type Mismatch Errors

// Error: Type 'string' is not assignable to type '`0x${string}`'
const address: `0x${string}` = userAddress;

// βœ… Solution
const contractAddress = getConfig(networkType).contractAddress as `0x${string}`;
const method = 'convertedB3trOf' as const;

// βœ… Validate addresses
import { humanAddress } from '@vechain/vechain-kit/utils';
const validatedAddress = humanAddress(address);

BigInt Serialization Errors

import { hashFn } from 'wagmi/query';
// Error: Do not know how to serialize a BigInt

// βœ… Solution: set wagmi's hashfn as default queryKeyHashFn
export const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      queryKeyHashFn: hashFn,
      retry: 0,
      retryOnMount: false,
      staleTime: 30000,
      // other options
    },
  },
})

React Query Issues

Cache Invalidation Not Working

Contract Interaction Issues

Migration from manual ABI lookup:

Transaction Building Fails

Performance Issues

Too Many Network Requests

Network Issues

RPC Endpoint Problems

Testing Issues

Mocking Problems

Last updated

Was this helpful?