hash

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAllParametersSet = errors.New("not all necessary parameters have been set")
	ErrFeltToBigInt        = errors.New("felt to BigInt error")
)

Functions

func CalculateDeprecatedTransactionHashCommon added in v0.8.0

func CalculateDeprecatedTransactionHashCommon(
	txHashPrefix *felt.Felt,
	version *felt.Felt,
	contractAddress *felt.Felt,
	entryPointSelector *felt.Felt,
	calldata *felt.Felt,
	maxFee *felt.Felt,
	chainID *felt.Felt,
	additionalData []*felt.Felt,
) *felt.Felt

CalculateDeprecatedTransactionHashCommon calculates the transaction hash common to be used in the StarkNet network - a unique identifier of the transaction. [specification]: https://github.com/starkware-libs/cairo-lang/blob/8276ac35830148a397e1143389f23253c8b80e93/src/starkware/starknet/core/os/transaction_hash/deprecated_transaction_hash.py#L29

Parameters:

  • txHashPrefix: The prefix of the transaction hash
  • version: The version of the transaction
  • contractAddress: The address of the contract
  • entryPointSelector: The selector of the entry point
  • calldata: The data of the transaction
  • maxFee: The maximum fee for the transaction
  • chainID: The ID of the blockchain
  • additionalData: Additional data to be included in the hash

Returns:

  • *felt.Felt: the calculated transaction hash

func ClassHash

func ClassHash(contract *contracts.ContractClass) *felt.Felt

ClassHash calculates the hash of a contract class.

It takes a contract class as input and calculates the hash by combining various elements of the class. The hash is calculated using the PoseidonArray function from the Curve package. The elements used in the hash calculation include the contract class version, constructor entry point, external entry point, L1 handler entry point, ABI, and Sierra program. The ABI is converted to bytes and then hashed using the StarknetKeccak function from the Curve package. Finally, the ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, and SierraProgamHash are combined using the PoseidonArray function from the Curve package.

Parameters:

  • contract: A contract class object of type contracts.ContractClass.

Returns:

  • *felt.Felt: a pointer to a felt.Felt object that represents the calculated hash.
  • error: an error object if there was an error during the hash calculation.

func CompiledClassHash

func CompiledClassHash(casmClass *contracts.CasmClass) (*felt.Felt, error)

CompiledClassHash calculates the hash of a compiled class in the Casm format.

Parameters:

  • casmClass: A `contracts.CasmClass` object

Returns:

  • *felt.Felt: a pointer to a felt.Felt object that represents the calculated hash.

func DataAvailabilityModeConc added in v0.8.0

func DataAvailabilityModeConc(feeDAMode, nonceDAMode rpc.DataAvailabilityMode) (uint64, error)

func TipAndResourcesHash added in v0.8.0

func TipAndResourcesHash(
	tip uint64,
	resourceBounds *rpc.ResourceBoundsMapping,
) (*felt.Felt, error)

func TransactionHashBroadcastDeclareV3 added in v0.8.0

func TransactionHashBroadcastDeclareV3(
	txn *rpc.BroadcastDeclareTxnV3,
	chainID *felt.Felt,
) (*felt.Felt, error)

TransactionHashBroadcastDeclareV3 calculates the transaction hash for a broadcast declare V3 transaction.

Parameters:

  • txn: The broadcast declare V3 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashDeclareV1 added in v0.8.0

func TransactionHashDeclareV1(txn *rpc.DeclareTxnV1, chainID *felt.Felt) (*felt.Felt, error)

TransactionHashDeclareV1 calculates the transaction hash for a declare V1 transaction.

Parameters:

  • txn: The declare V1 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashDeclareV2 added in v0.8.0

func TransactionHashDeclareV2(
	txn *rpc.DeclareTxnV2,
	chainID *felt.Felt,
) (*felt.Felt, error)

TransactionHashDeclareV2 calculates the transaction hash for a declare V2 transaction.

Parameters:

  • txn: The declare V2 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashDeclareV3 added in v0.8.0

func TransactionHashDeclareV3(
	txn *rpc.DeclareTxnV3,
	chainID *felt.Felt,
) (*felt.Felt, error)

TransactionHashDeclareV3 calculates the transaction hash for a declare V3 transaction.

Parameters:

  • txn: The declare V3 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashDeployAccountV1 added in v0.8.0

func TransactionHashDeployAccountV1(
	txn *rpc.DeployAccountTxnV1,
	contractAddress, chainID *felt.Felt,
) (*felt.Felt, error)

TransactionHashDeployAccountV1 calculates the transaction hash for a deploy account V1 transaction.

Parameters:

  • txn: The deploy account V1 transaction to calculate the hash for
  • contractAddress: The contract address as parameters as a *felt.Felt
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashDeployAccountV3 added in v0.8.0

func TransactionHashDeployAccountV3(
	txn *rpc.DeployAccountTxnV3,
	contractAddress, chainID *felt.Felt,
) (*felt.Felt, error)

TransactionHashDeployAccountV3 calculates the transaction hash for a deploy account V3 transaction.

Parameters:

  • txn: The deploy account V3 transaction to calculate the hash for
  • contractAddress: The contract address as parameters as a *felt.Felt
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashInvokeV0 added in v0.8.0

func TransactionHashInvokeV0(txn *rpc.InvokeTxnV0, chainID *felt.Felt) (*felt.Felt, error)

TransactionHashInvokeV0 calculates the transaction hash for a invoke V0 transaction.

Parameters:

  • txn: The invoke V0 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashInvokeV1 added in v0.8.0

func TransactionHashInvokeV1(txn *rpc.InvokeTxnV1, chainID *felt.Felt) (*felt.Felt, error)

TransactionHashInvokeV1 calculates the transaction hash for a invoke V1 transaction.

Parameters:

  • txn: The invoke V1 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

func TransactionHashInvokeV3 added in v0.8.0

func TransactionHashInvokeV3(txn *rpc.InvokeTxnV3, chainID *felt.Felt) (*felt.Felt, error)

TransactionHashInvokeV3 calculates the transaction hash for a invoke V3 transaction.

Parameters:

  • txn: The invoke V3 transaction to calculate the hash for
  • chainID: The chain ID as a *felt.Felt

Returns:

  • *felt.Felt: the calculated transaction hash
  • error: an error if any

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL