Skip to main content
Version: Next

Migrate from v6 to v7

This document only covers the features present in v6 which have changed in some significant way in v7.

If you encounter any missing changes, please let us know and we will update this guide.

Fetch dependencies​

isomorphic-fetch and fetch-cookie have been removed as dependencies.

For users who might require the features of either library, a baseFetch override parameter has been enabled for the RpcProvider and RpcChannel classes, including classes that inherit from them such as Account and WalletAccount.

import makeFetchCookie from 'fetch-cookie';
import isomorphicFetch from 'isomorphic-fetch';

const provider = new RpcProvider({
baseFetch: makeFetchCookie(isomorphicFetch),
});

Rpc compatibility​

Starknet.js v6 is compatible with Starknet RPC 0.6 and 0.7 nodes.

Starknet.js v7 drops support for RPC 0.6, and introduces support for RPC 0.8, it supports RPC 0.7 and 0.8 nodes.

By default, Starknet.js v7 uses RPC 0.8 with V3 transactions (STRK fees). This means that you can no longer execute V1 transactions (ETH fees) by default.

RPC 0.7RPC 0.8
(default)
V1 tx (ETH fees)PossibleImpossible
V3 tx (STRK fees)DefaultDefault

You can configure your code to use RPC 0.7 with ETH and STRK fees available by using the following options:

  • Define specVersion: '0.7' when instantiating an RpcProvider
  • Use config.set('legacyMode', true) to enable V1 transactions
  • Use logger.setLogLevel('ERROR') if you want to remove the warnings when processing V1 transactions
import { RpcProvider, Account, config, logger, ETransactionVersion } from 'starknet';

const myProvider = new RpcProvider({
nodeUrl: 'https://free-rpc.nethermind.io/sepolia-juno/v0_7',
specVersion: '0.7',
});

config.set('legacyMode', true);

logger.setLogLevel('ERROR');

With the above settings the code still uses V3 transactions with RPC 0.7 by default. To utilize V1 transactions there are two approaches:

  • either configure it at the Account instance level by setting the appropriate constructor parameter:
const account0 = new Account(
myProvider,
accountAddress0,
privateKey0,
undefined,
ETransactionVersion.V2
);
  • or configure it for individual method invocations by setting the corresponding options parameter property:
const res = await account0.execute(myCall, { version: 1 });

Transaction receipt​

In the ReceiptTx class, the status isRejected has been removed.

Removed deprecated functionalities​

RpcProvider​

methodreplacement
getPendingTransactions(...)getBlockWithTxHashes(BlockTag.PENDING)
getBlock(BlockTag.PENDING)
getEstimateFee(...)getInvokeEstimateFee(...)
getDeclareEstimateFee(...)
getDeployAccountEstimateFee(...)

Account​

methoddetails
execute(...)The deprecated execute(transactions, abis?, transactionsDetail?) override with the optional (and unused) abis parameter has been removed.

execute(transactions, transactionsDetail?) now only accepts two parameters and should be used as such.
verifyMessage(...)

verifyMessageHash(...)
The deprecated Account message verification methods have been removed.

The RpcProvider verifyMessageInStarknet(...) method should be used instead.

WalletAccount​

When initializing a WalletAccount instance through the constructor new WalletAccount(...) the address parameter has been made mandatory with the deprecated eager address retrieval removed.

To initialize a WalletAccount instance WalletAccount.connect(...) should be used.

Removed namespace​

The number namespace alias has been removed in favor of num as noted in the v5 migration guide.

Removed utility functions​

namespacefunctionreplacement
encodestringToArrayBuffer(...)utf8ToArray(...)
jsonstringifyAlwaysAsBig(...)stringify(...)
starkmakeAddress(...)validateAndParseAddress(...)
transactionfromCallsToExecuteCalldataWithNonce(...)
transformCallsToMulticallArrays_cairo1(...)
/
  • the CallStruct type that was used by the transaction methods has also been removed

Removed type alias exports​

Multiple TypeScript types have had their old location re-exports removed. They are no longer available within their old namespace but are available as direct imports: import { *type* } from 'starknet'.

namespacetype
numBigNumberish
typedDataTypedDataRevision
StarknetEnumType
StarknetMerkleType
StarknetType
StarknetDomain
TypedData
uint256UINT_128_MAX
UINT_256_MAX