Skip to main content
Version: 5.24.3

Namespace: hash

Namespaces​

Variables​

transactionVersion​

• Const transactionVersion: 1n

Defined in​

src/utils/hash.ts:38


transactionVersion_2​

• Const transactionVersion_2: 2n

Defined in​

src/utils/hash.ts:39


feeTransactionVersion​

• Const feeTransactionVersion: bigint = BN_FEE_TRANSACTION_VERSION_1

Defined in​

src/utils/hash.ts:40


feeTransactionVersion_2​

• Const feeTransactionVersion_2: bigint = BN_FEE_TRANSACTION_VERSION_2

Defined in​

src/utils/hash.ts:41

Functions​

getVersionsByType​

â–¸ getVersionsByType(versionType?): Object

Return transaction versions based on version type, default version type is 'transaction'

Parameters​

NameType
versionType?"fee" | "transaction"

Returns​

Object

NameType
v1bigint
v2bigint

Defined in​

src/utils/hash.ts:46


computeHashOnElements​

â–¸ computeHashOnElements(data): string

Compute pedersen hash from data

Parameters​

NameType
dataBigNumberish[]

Returns​

string

format: hex-string - pedersen hash

Defined in​

src/utils/hash.ts:56


calculateTransactionHashCommon​

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

Calculate transaction pedersen hash for common properties

Following implementation is based on this python implementation #

Parameters​

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

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:68


calculateDeployTransactionHash​

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

Calculate deploy transaction hash

Parameters​

NameTypeDefault value
contractAddressBigNumberishundefined
constructorCalldataRawCalldataundefined
versionBigNumberishundefined
chainIdStarknetChainIdundefined
constructorNamestring'constructor'

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:96


calculateDeclareTransactionHash​

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

Calculate declare transaction hash

Parameters​

NameTypeDescription
classHashstringhex-string
senderAddressBigNumberish-
versionBigNumberish-
maxFeeBigNumberish-
chainIdStarknetChainId-
nonceBigNumberish-
compiledClassHash?stringhex-string

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:120


calculateDeployAccountTransactionHash​

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

Calculate deploy_account transaction hash

Parameters​

NameType
contractAddressBigNumberish
classHashBigNumberish
constructorCalldataRawCalldata
saltBigNumberish
versionBigNumberish
maxFeeBigNumberish
chainIdStarknetChainId
nonceBigNumberish

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:145


calculateTransactionHash​

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

Calculate invoke transaction hash

Parameters​

NameType
contractAddressBigNumberish
versionBigNumberish
calldataRawCalldata
maxFeeBigNumberish
chainIdStarknetChainId
nonceBigNumberish

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:173


calculateContractAddressFromHash​

â–¸ calculateContractAddressFromHash(salt, classHash, constructorCalldata, deployerAddress): string

Calculate contract address from class hash

Parameters​

NameType
saltBigNumberish
classHashBigNumberish
constructorCalldataRawArgs
deployerAddressBigNumberish

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:197


formatSpaces​

â–¸ formatSpaces(json): string

Format json-string to conform starknet json-string

Parameters​

NameTypeDescription
jsonstringjson-string

Returns​

string

format: json-string

Defined in​

src/utils/hash.ts:234


default​

â–¸ default(compiledContract): string

Compute hinted class hash for legacy compiled contract (Cairo 0)

Parameters​

NameType
compiledContractLegacyCompiledContract

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:256


computeLegacyContractClassHash​

â–¸ computeLegacyContractClassHash(contract): string

Computes the class hash for legacy compiled contract (Cairo 0)

Parameters​

NameType
contractstring | LegacyCompiledContract

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:268


computeCompiledClassHash​

â–¸ computeCompiledClassHash(casm): string

Compute compiled class hash for contract (Cairo 1)

Parameters​

NameType
casmCairoAssembly

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:326


computeSierraContractClassHash​

â–¸ computeSierraContractClassHash(sierra): string

Compute sierra contract class hash (Cairo 1)

Parameters​

NameType
sierraCompiledSierra

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:371


computeContractClassHash​

â–¸ computeContractClassHash(contract): string

Compute ClassHash (sierra or legacy) based on provided contract

Parameters​

NameType
contractstring | CompiledContract

Returns​

string

format: hex-string

Defined in​

src/utils/hash.ts:408


keccakBn​

â–¸ keccakBn(value): string

Calculate hex-string keccak hash for a given BigNumberish

BigNumberish -> hex-string keccak hash

Parameters​

NameType
valueBigNumberish

Returns​

string

format: hex-string

Defined in​

src/utils/selector.ts:14


starknetKeccak​

â–¸ starknetKeccak(str): bigint

Calculate bigint keccak hash for a given string

String -> bigint keccak hash

Reference

Parameters​

NameTypeDescription
strstringthe value you want to get the keccak hash from

Returns​

bigint

starknet keccak hash as BigInt

Defined in​

src/utils/selector.ts:39


getSelectorFromName​

â–¸ getSelectorFromName(funcName): string

Calculate hex-string selector for a given abi-function-name

Abi-function-name -> hex-string selector

Reference

Parameters​

NameTypeDescription
funcNamestringascii-string of 'abi function name'

Returns​

string

format: hex-string; selector for 'abi function name'

Defined in​

src/utils/selector.ts:54


getSelector​

â–¸ getSelector(value): string

Calculate hex-string selector from abi-function-name, decimal string or hex string

('abi-function-name' or dec-string or hex-string) -> hex-string selector

Parameters​

NameTypeDescription
valuestringhex-string | dec-string | ascii-string

Returns​

string

format: hex-string

Defined in​

src/utils/selector.ts:67