Skip to main content
Version: 5.19.5

Namespace: hash

Namespaces

Variables

transactionVersion

Const transactionVersion: 1n

Defined in

src/utils/hash.ts:30


transactionVersion_2

Const transactionVersion_2: 2n

Defined in

src/utils/hash.ts:31


feeTransactionVersion

Const feeTransactionVersion: bigint

Defined in

src/utils/hash.ts:33


feeTransactionVersion_2

Const feeTransactionVersion_2: bigint

Defined in

src/utils/hash.ts:34

Functions

getVersionsByType

getVersionsByType(versionType?): Object

Return versions based on version type, default transaction versions

Parameters

NameTypeDescription
versionType?"fee" | "transaction"'fee' | 'transaction'

Returns

Object

versions { v1: bigint; v2: bigint; }

NameType
v1bigint
v2bigint

Defined in

src/utils/hash.ts:41


computeHashOnElements

computeHashOnElements(data): string

Parameters

NameType
dataBigNumberish[]

Returns

string

Defined in

src/utils/hash.ts:47


calculateTransactionHashCommon

calculateTransactionHashCommon(txHashPrefix, version, contractAddress, entryPointSelector, calldata, maxFee, chainId, additionalData?): string

Parameters

NameTypeDefault value
txHashPrefixTransactionHashPrefixundefined
versionBigNumberishundefined
contractAddressBigNumberishundefined
entryPointSelectorBigNumberishundefined
calldataRawCalldataundefined
maxFeeBigNumberishundefined
chainIdStarknetChainIdundefined
additionalDataBigNumberish[][]

Returns

string

Defined in

src/utils/hash.ts:56


calculateDeployTransactionHash

calculateDeployTransactionHash(contractAddress, constructorCalldata, version, chainId, constructorName?): string

Parameters

NameTypeDefault value
contractAddressBigNumberishundefined
constructorCalldataRawCalldataundefined
versionBigNumberishundefined
chainIdStarknetChainIdundefined
constructorNamestring'constructor'

Returns

string

Defined in

src/utils/hash.ts:80


calculateDeclareTransactionHash

calculateDeclareTransactionHash(classHash, senderAddress, version, maxFee, chainId, nonce, compiledClassHash?): string

Parameters

NameType
classHashstring
senderAddressBigNumberish
versionBigNumberish
maxFeeBigNumberish
chainIdStarknetChainId
nonceBigNumberish
compiledClassHash?string

Returns

string

Defined in

src/utils/hash.ts:98


calculateDeployAccountTransactionHash

calculateDeployAccountTransactionHash(contractAddress, classHash, constructorCalldata, salt, version, maxFee, chainId, nonce): string

Parameters

NameType
contractAddressBigNumberish
classHashBigNumberish
constructorCalldataRawCalldata
saltBigNumberish
versionBigNumberish
maxFeeBigNumberish
chainIdStarknetChainId
nonceBigNumberish

Returns

string

Defined in

src/utils/hash.ts:119


calculateTransactionHash

calculateTransactionHash(contractAddress, version, calldata, maxFee, chainId, nonce): string

Parameters

NameType
contractAddressBigNumberish
versionBigNumberish
calldataRawCalldata
maxFeeBigNumberish
chainIdStarknetChainId
nonceBigNumberish

Returns

string

Defined in

src/utils/hash.ts:143


calculateContractAddressFromHash

calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress): string

Parameters

NameType
saltBigNumberish
classHashBigNumberish
constructorCalldataRawArgs
deployerAddressBigNumberish

Returns

string

Defined in

src/utils/hash.ts:163


formatSpaces

formatSpaces(json): string

Parameters

NameType
jsonstring

Returns

string

Defined in

src/utils/hash.ts:196


default

default(compiledContract): string

Parameters

NameType
compiledContractLegacyCompiledContract

Returns

string

Defined in

src/utils/hash.ts:214


computeLegacyContractClassHash

computeLegacyContractClassHash(contract): string

Parameters

NameType
contractstring | LegacyCompiledContract

Returns

string

Defined in

src/utils/hash.ts:223


computeCompiledClassHash

computeCompiledClassHash(casm): string

Parameters

NameType
casmCairoAssembly

Returns

string

Defined in

src/utils/hash.ts:276


computeSierraContractClassHash

computeSierraContractClassHash(sierra): string

Parameters

NameType
sierraCompiledSierra

Returns

string

Defined in

src/utils/hash.ts:317


computeContractClassHash

computeContractClassHash(contract): string

Compute ClassHash (sierra or legacy) based on provided contract

Parameters

NameTypeDescription
contractstring | CompiledContractCompiledContract | CompiledSierra | string

Returns

string

HexString ClassHash

Defined in

src/utils/hash.ts:355


keccakBn

keccakBn(value): string

Keccak hash BigNumberish value

Parameters

NameTypeDescription
valueBigNumberishBigNumberish

Returns

string

string - hexadecimal string

Defined in

src/utils/selector.ts:13


starknetKeccak

starknetKeccak(value): bigint

Function to get the starknet keccak hash from a string

Reference

Parameters

NameTypeDescription
valuestringstring you want to get the starknetKeccak hash from

Returns

bigint

starknet keccak hash as BigNumber

Defined in

src/utils/selector.ts:35


getSelectorFromName

getSelectorFromName(funcName): string

Function to get the hex selector from a given function name

Reference

Parameters

NameTypeDescription
funcNamestringselectors abi function name

Returns

string

hex selector of given abi function name

Defined in

src/utils/selector.ts:48


getSelector

getSelector(value): string

Function to get hex selector from function name, decimal string or hex string

Parameters

NameTypeDescription
valuestringhex string | decimal string | string

Returns

string

Hex selector

Defined in

src/utils/selector.ts:58