Namespace: hash
Namespaces​
Variables​
transactionVersion​
• Const
transactionVersion: 1n
Defined in​
transactionVersion_2​
• Const
transactionVersion_2: 2n
Defined in​
feeTransactionVersion​
• Const
feeTransactionVersion: bigint
= BN_FEE_TRANSACTION_VERSION_1
Defined in​
feeTransactionVersion_2​
• Const
feeTransactionVersion_2: bigint
= BN_FEE_TRANSACTION_VERSION_2
Defined in​
Functions​
getVersionsByType​
â–¸ getVersionsByType(versionType?
): Object
Return transaction versions based on version type, default version type is 'transaction'
Parameters​
Name | Type |
---|---|
versionType? | "fee" | "transaction" |
Returns​
Object
Name | Type |
---|---|
v1 | bigint |
v2 | bigint |
Defined in​
computeHashOnElements​
â–¸ computeHashOnElements(data
): string
Compute pedersen hash from data
Parameters​
Name | Type |
---|---|
data | BigNumberish [] |
Returns​
string
format: hex-string - pedersen hash
Defined in​
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​
Name | Type | Default value |
---|---|---|
txHashPrefix | TransactionHashPrefix | undefined |
version | BigNumberish | undefined |
contractAddress | BigNumberish | undefined |
entryPointSelector | BigNumberish | undefined |
calldata | RawCalldata | undefined |
maxFee | BigNumberish | undefined |
chainId | StarknetChainId | undefined |
additionalData | BigNumberish [] | [] |
Returns​
string
format: hex-string
Defined in​
calculateDeployTransactionHash​
â–¸ calculateDeployTransactionHash(contractAddress
, constructorCalldata
, version
, chainId
, constructorName?
): string
Calculate deploy transaction hash
Parameters​
Name | Type | Default value |
---|---|---|
contractAddress | BigNumberish | undefined |
constructorCalldata | RawCalldata | undefined |
version | BigNumberish | undefined |
chainId | StarknetChainId | undefined |
constructorName | string | 'constructor' |
Returns​
string
format: hex-string
Defined in​
calculateDeclareTransactionHash​
â–¸ calculateDeclareTransactionHash(classHash
, senderAddress
, version
, maxFee
, chainId
, nonce
, compiledClassHash?
): string
Calculate declare transaction hash
Parameters​
Name | Type | Description |
---|---|---|
classHash | string | hex-string |
senderAddress | BigNumberish | - |
version | BigNumberish | - |
maxFee | BigNumberish | - |
chainId | StarknetChainId | - |
nonce | BigNumberish | - |
compiledClassHash? | string | hex-string |
Returns​
string
format: hex-string
Defined in​
calculateDeployAccountTransactionHash​
â–¸ calculateDeployAccountTransactionHash(contractAddress
, classHash
, constructorCalldata
, salt
, version
, maxFee
, chainId
, nonce
): string
Calculate deploy_account transaction hash
Parameters​
Name | Type |
---|---|
contractAddress | BigNumberish |
classHash | BigNumberish |
constructorCalldata | RawCalldata |
salt | BigNumberish |
version | BigNumberish |
maxFee | BigNumberish |
chainId | StarknetChainId |
nonce | BigNumberish |
Returns​
string
format: hex-string
Defined in​
calculateTransactionHash​
â–¸ calculateTransactionHash(contractAddress
, version
, calldata
, maxFee
, chainId
, nonce
): string
Calculate invoke transaction hash
Parameters​
Name | Type |
---|---|
contractAddress | BigNumberish |
version | BigNumberish |
calldata | RawCalldata |
maxFee | BigNumberish |
chainId | StarknetChainId |
nonce | BigNumberish |
Returns​
string
format: hex-string
Defined in​
calculateContractAddressFromHash​
â–¸ calculateContractAddressFromHash(salt
, classHash
, constructorCalldata
, deployerAddress
): string
Calculate contract address from class hash
Parameters​
Name | Type |
---|---|
salt | BigNumberish |
classHash | BigNumberish |
constructorCalldata | RawArgs |
deployerAddress | BigNumberish |
Returns​
string
format: hex-string
Defined in​
formatSpaces​
â–¸ formatSpaces(json
): string
Format json-string to conform starknet json-string
Parameters​
Name | Type | Description |
---|---|---|
json | string | json-string |
Returns​
string
format: json-string
Defined in​
default​
â–¸ default(compiledContract
): string
Compute hinted class hash for legacy compiled contract (Cairo 0)
Parameters​
Name | Type |
---|---|
compiledContract | LegacyCompiledContract |
Returns​
string
format: hex-string
Defined in​
computeLegacyContractClassHash​
â–¸ computeLegacyContractClassHash(contract
): string
Computes the class hash for legacy compiled contract (Cairo 0)
Parameters​
Name | Type |
---|---|
contract | string | LegacyCompiledContract |
Returns​
string
format: hex-string
Defined in​
computeCompiledClassHash​
â–¸ computeCompiledClassHash(casm
): string
Compute compiled class hash for contract (Cairo 1)
Parameters​
Name | Type |
---|---|
casm | CairoAssembly |
Returns​
string
format: hex-string
Defined in​
computeSierraContractClassHash​
â–¸ computeSierraContractClassHash(sierra
): string
Compute sierra contract class hash (Cairo 1)
Parameters​
Name | Type |
---|---|
sierra | CompiledSierra |
Returns​
string
format: hex-string
Defined in​
computeContractClassHash​
â–¸ computeContractClassHash(contract
): string
Compute ClassHash (sierra or legacy) based on provided contract
Parameters​
Name | Type |
---|---|
contract | string | CompiledContract |
Returns​
string
format: hex-string
Defined in​
keccakBn​
â–¸ keccakBn(value
): string
Calculate hex-string keccak hash for a given BigNumberish
BigNumberish -> hex-string keccak hash
Parameters​
Name | Type |
---|---|
value | BigNumberish |
Returns​
string
format: hex-string
Defined in​
starknetKeccak​
â–¸ starknetKeccak(str
): bigint
Calculate bigint keccak hash for a given string
String -> bigint keccak hash
Parameters​
Name | Type | Description |
---|---|---|
str | string | the value you want to get the keccak hash from |
Returns​
bigint
starknet keccak hash as BigInt
Defined in​
getSelectorFromName​
â–¸ getSelectorFromName(funcName
): string
Calculate hex-string selector for a given abi-function-name
Abi-function-name -> hex-string selector
Parameters​
Name | Type | Description |
---|---|---|
funcName | string | ascii-string of 'abi function name' |
Returns​
string
format: hex-string; selector for 'abi function name'
Defined in​
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​
Name | Type | Description |
---|---|---|
value | string | hex-string | dec-string | ascii-string |
Returns​
string
format: hex-string