Skip to main content
Version: Next

Namespace: hash

Namespaces​

Functions​

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

Example

const selector: string = getSelector("myFunction");
// selector = "0x7e44bafo"

const selector1: string = getSelector("0x123abc");
// selector1 = "0x123abc"

const selector2: string = getSelector("123456");
// selector2 = "0x1e240"

Defined in​

src/utils/selector.ts:78


calculateInvokeTransactionHash​

β–Έ calculateInvokeTransactionHash(args): string

Parameters​

NameType
argsCalcInvokeTxHashArgs

Returns​

string

Defined in​

src/utils/hash/transactionHash/index.ts:60


calculateDeclareTransactionHash​

β–Έ calculateDeclareTransactionHash(args): string

Parameters​

NameType
argsCalcDeclareTxHashArgs

Returns​

string

Defined in​

src/utils/hash/transactionHash/index.ts:122


calculateDeployAccountTransactionHash​

β–Έ calculateDeployAccountTransactionHash(args): string

Parameters​

NameType
argsCalcDeployAccountTxHashArgs

Returns​

string

Defined in​

src/utils/hash/transactionHash/index.ts:191


computePedersenHash​

β–Έ computePedersenHash(a, b): string

Parameters​

NameType
aBigNumberish
bBigNumberish

Returns​

string

Defined in​

src/utils/hash/classHash.ts:27


computePoseidonHash​

β–Έ computePoseidonHash(a, b): string

Parameters​

NameType
aBigNumberish
bBigNumberish

Returns​

string

Defined in​

src/utils/hash/classHash.ts:31


computeHashOnElements​

β–Έ computeHashOnElements(data): string

Compute pedersen hash from data

Parameters​

NameType
dataBigNumberish[]

Returns​

string

format: hex-string - pedersen hash

Defined in​

src/utils/hash/classHash.ts:39


computePoseidonHashOnElements​

β–Έ computePoseidonHashOnElements(data): string

Parameters​

NameType
dataBigNumberish[]

Returns​

string

Defined in​

src/utils/hash/classHash.ts:47


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/classHash.ts:55


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/classHash.ts:93


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/classHash.ts:127


hashByteCodeSegments​

β–Έ hashByteCodeSegments(casm): bigint

Compute hash of the bytecode for Sierra v1.5.0 onwards (Cairo 2.6.0) Each segment is Poseidon hashed. The global hash is : 1 + PoseidonHash(len0, h0, len1, h1, ...)

Parameters​

NameTypeDescription
casmCairoAssemblycompiled Sierra CASM file content.

Returns​

bigint

the bytecode hash as bigint.

Defined in​

src/utils/hash/classHash.ts:189


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/classHash.ts:206


computeSierraContractClassHash​

β–Έ computeSierraContractClassHash(sierra): string

Compute sierra contract class hash (Cairo 1)

Parameters​

NameType
sierraCompiledSierra

Returns​

string

format: hex-string

Defined in​

src/utils/hash/classHash.ts:253


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/classHash.ts:290


computePedersenHashOnElements​

β–Έ computePedersenHashOnElements(data): string

Compute pedersen hash from data

Parameters​

NameType
dataBigNumberish[]

Returns​

string

format: hex-string - pedersen hash

Defined in​

src/utils/hash/classHash.ts:39