starknet

package
v0.16.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDeprecatedCompiledClassDefinition added in v0.9.3

func IsDeprecatedCompiledClassDefinition(definition json.RawMessage) (bool, error)

Types

type Block

type Block struct {
	Hash                  *felt.Felt            `json:"block_hash"`
	ParentHash            *felt.Felt            `json:"parent_block_hash"`
	Number                uint64                `json:"block_number"`
	StateRoot             *felt.Felt            `json:"state_root"`
	TransactionCommitment *felt.Felt            `json:"transaction_commitment"`
	EventCommitment       *felt.Felt            `json:"event_commitment"`
	ReceiptCommitment     *felt.Felt            `json:"receipt_commitment"`
	StateDiffCommitment   *felt.Felt            `json:"state_diff_commitment"`
	StateDiffLength       uint64                `json:"state_diff_length"`
	Status                string                `json:"status"`
	Transactions          []*Transaction        `json:"transactions"`
	Timestamp             uint64                `json:"timestamp"`
	Version               string                `json:"starknet_version"`
	Receipts              []*TransactionReceipt `json:"transaction_receipts"`
	SequencerAddress      *felt.Felt            `json:"sequencer_address"`
	L1GasPrice            *GasPrice             `json:"l1_gas_price"`
	L2GasPrice            *GasPrice             `json:"l2_gas_price"`
	L1DAMode              L1DAMode              `json:"l1_da_mode"`
	L1DataGasPrice        *GasPrice             `json:"l1_data_gas_price"`

	// TODO we can remove the GasPrice method and the GasPriceLegacy field
	// once v0.13 lands on mainnet. In the meantime, we include both to support
	// pre-v0.13 jsons, where `eth_l1_gas_price` was called `gas_price`.
	GasPriceLegacy *felt.Felt `json:"gas_price"`
	// TODO these fields were replaced by `l1_gas_price` in v0.13.1
	GasPriceWEI *felt.Felt `json:"eth_l1_gas_price"`
	GasPriceFRI *felt.Felt `json:"strk_l1_gas_price"`
}

Block object returned by the feeder in JSON format for "get_block" endpoint

func (*Block) L1GasPriceETH added in v0.13.0

func (b *Block) L1GasPriceETH() *felt.Felt

func (*Block) L1GasPriceSTRK added in v0.13.0

func (b *Block) L1GasPriceSTRK() *felt.Felt

type BlockHeader added in v0.15.22

type BlockHeader struct {
	Hash   *felt.Felt `json:"block_hash"`
	Number uint64     `json:"block_number"`
}

BlockHeader object returned by the feeder in JSON format for "get_block" endpoint with headerOnly=true. Explicitly not making it part of `Block` to avoid the huge refactor.

type BlockTrace

type BlockTrace struct {
	Traces []TransactionTrace `json:"traces"`
}

type BuiltinInstanceCounter

type BuiltinInstanceCounter struct {
	Pedersen     uint64 `json:"pedersen_builtin"`
	RangeCheck   uint64 `json:"range_check_builtin"`
	Bitwise      uint64 `json:"bitwise_builtin"`
	Output       uint64 `json:"output_builtin"`
	Ecdsa        uint64 `json:"ecdsa_builtin"`
	EcOp         uint64 `json:"ec_op_builtin"`
	Keccak       uint64 `json:"keccak_builtin"`
	Poseidon     uint64 `json:"poseidon_builtin"`
	SegmentArena uint64 `json:"segment_arena_builtin"`
	AddMod       uint64 `json:"add_mod_builtin"`
	MulMod       uint64 `json:"mul_mod_builtin"`
	RangeCheck96 uint64 `json:"range_check96_builtin"`
}

type CasmClass added in v0.15.9

type CasmClass struct {
	Prime                  string          `json:"prime"`
	Bytecode               []*felt.Felt    `json:"bytecode"`
	Hints                  json.RawMessage `json:"hints"`
	PythonicHints          json.RawMessage `json:"pythonic_hints"`
	CompilerVersion        string          `json:"compiler_version"`
	BytecodeSegmentLengths *SegmentLengths `json:"bytecode_segment_lengths,omitempty"`
	EntryPoints            struct {
		External    []CompiledEntryPoint `json:"EXTERNAL"`
		L1Handler   []CompiledEntryPoint `json:"L1_HANDLER"`
		Constructor []CompiledEntryPoint `json:"CONSTRUCTOR"`
	} `json:"entry_points_by_type"`
}

type ClassDefinition

type ClassDefinition struct {
	DeprecatedCairo *DeprecatedCairoClass
	Sierra          *SierraClass
}

func (*ClassDefinition) UnmarshalJSON

func (c *ClassDefinition) UnmarshalJSON(data []byte) error

type CompiledEntryPoint added in v0.9.3

type CompiledEntryPoint struct {
	Selector *felt.Felt `json:"selector"`
	Offset   uint64     `json:"offset"`
	Builtins []string   `json:"builtins"`
}

type DataAvailability added in v0.11.0

type DataAvailability struct {
	L1Gas     uint64 `json:"l1_gas"`
	L1DataGas uint64 `json:"l1_data_gas"`
}

type DataAvailabilityMode added in v0.8.0

type DataAvailabilityMode uint32
const (
	DAModeL1 DataAvailabilityMode = iota
	DAModeL2
)

type DeprecatedCairoClass added in v0.15.9

type DeprecatedCairoClass struct {
	Abi         json.RawMessage `json:"abi"`
	EntryPoints EntryPoints     `json:"entry_points_by_type"`
	Program     json.RawMessage `json:"program"`
}

type DeprecatedTransactionStatus deprecated added in v0.15.20

type DeprecatedTransactionStatus struct {
	Status           string                    `json:"status"`
	FinalityStatus   FinalityStatus            `json:"finality_status"`
	ExecutionStatus  ExecutionStatus           `json:"execution_status"`
	BlockHash        *felt.Felt                `json:"block_hash"`
	BlockNumber      uint64                    `json:"block_number"`
	TransactionIndex uint64                    `json:"transaction_index"`
	Transaction      *Transaction              `json:"transaction"`
	RevertError      string                    `json:"revert_error"`
	FailureReason    *TransactionFailureReason `json:"transaction_failure_reason,omitempty"`
}

Deprecated: Use TransactionStatus with Client.DeprecatedTransactionStatus() instead.

type EntryPoint

type EntryPoint struct {
	Selector *felt.Felt        `json:"selector"`
	Offset   *EntryPointOffset `json:"offset"`
}

type EntryPointOffset added in v0.16.0

type EntryPointOffset felt.Felt

EntryPointOffset accepts both decimal integers and hex strings in JSON, since the feeder gateway has used both formats across different class versions.

func (EntryPointOffset) MarshalJSON added in v0.16.0

func (o EntryPointOffset) MarshalJSON() ([]byte, error)

func (EntryPointOffset) String added in v0.16.0

func (o EntryPointOffset) String() string

func (*EntryPointOffset) UnmarshalJSON added in v0.16.0

func (o *EntryPointOffset) UnmarshalJSON(data []byte) error

type EntryPoints

type EntryPoints struct {
	Constructor []EntryPoint `json:"CONSTRUCTOR"`
	External    []EntryPoint `json:"EXTERNAL"`
	L1Handler   []EntryPoint `json:"L1_HANDLER"`
}

type Event

type Event struct {
	From *felt.Felt   `json:"from_address"`
	Data []*felt.Felt `json:"data"`
	Keys []*felt.Felt `json:"keys"`
}

type ExecutionResources

type ExecutionResources struct {
	Steps                  uint64                 `json:"n_steps"`
	BuiltinInstanceCounter BuiltinInstanceCounter `json:"builtin_instance_counter"`
	MemoryHoles            uint64                 `json:"n_memory_holes"`
	DataAvailability       *DataAvailability      `json:"data_availability"`
	TotalGasConsumed       *GasConsumed           `json:"total_gas_consumed"`
}

type ExecutionStatus

type ExecutionStatus uint8
const (
	Succeeded ExecutionStatus = iota + 1
	Reverted
	Rejected
)

func (*ExecutionStatus) UnmarshalText added in v0.12.3

func (es *ExecutionStatus) UnmarshalText(data []byte) error

type FeeTokenAddresses added in v0.15.7

type FeeTokenAddresses struct {
	StrkL2TokenAddress felt.Felt `json:"strk_l2_token_address"`
	EthL2TokenAddress  felt.Felt `json:"eth_l2_token_address"`
}

FeeTokenAddresses holds the L2 token contract addresses for STRK and ETH as returned by the feeder gateway's "get_contract_addresses" endpoint. These addresses are used to identify the respective fee tokens on the network.

type FinalityStatus

type FinalityStatus uint8
const (
	AcceptedOnL2 FinalityStatus = iota + 1
	AcceptedOnL1
	NotReceived
	Received
	PreConfirmed
	Candidate
)

func (*FinalityStatus) UnmarshalText added in v0.12.3

func (fs *FinalityStatus) UnmarshalText(data []byte) error

type FunctionInvocation

type FunctionInvocation struct {
	CallerAddress      felt.Felt              `json:"caller_address"`
	ContractAddress    felt.Felt              `json:"contract_address"`
	Calldata           []felt.Felt            `json:"calldata"`
	CallType           string                 `json:"call_type"`
	ClassHash          *felt.Felt             `json:"class_hash"`
	Selector           *felt.Felt             `json:"selector"`
	EntryPointType     string                 `json:"entry_point_type"`
	Result             []felt.Felt            `json:"result"`
	Failed             bool                   `json:"failed"`
	ExecutionResources ExecutionResources     `json:"execution_resources"`
	InternalCalls      []FunctionInvocation   `json:"internal_calls"`
	Events             []OrderedEvent         `json:"events"`
	Messages           []OrderedL2toL1Message `json:"messages"`
}

type GasConsumed added in v0.12.0

type GasConsumed struct {
	L1Gas     uint64 `json:"l1_gas"`
	L1DataGas uint64 `json:"l1_data_gas"`
	L2Gas     uint64 `json:"l2_gas"`
}

type GasPrice added in v0.11.0

type GasPrice struct {
	PriceInWei *felt.Felt `json:"price_in_wei"`
	PriceInFri *felt.Felt `json:"price_in_fri"`
}

type L1DAMode added in v0.11.0

type L1DAMode uint
const (
	Calldata L1DAMode = iota
	Blob
)

func (*L1DAMode) UnmarshalJSON added in v0.11.0

func (m *L1DAMode) UnmarshalJSON(data []byte) error

type L1ToL2Message

type L1ToL2Message struct {
	From     string       `json:"from_address"`
	Payload  []*felt.Felt `json:"payload"`
	Selector *felt.Felt   `json:"selector"`
	To       *felt.Felt   `json:"to_address"`
	Nonce    *felt.Felt   `json:"nonce"`
}

type L2ToL1Message

type L2ToL1Message struct {
	From    *felt.Felt   `json:"from_address"`
	Payload []*felt.Felt `json:"payload"`
	To      string       `json:"to_address"`
}

type OrderedEvent

type OrderedEvent struct {
	Order uint64      `json:"order"`
	Keys  []felt.Felt `json:"keys"`
	Data  []felt.Felt `json:"data"`
}

type OrderedL2toL1Message

type OrderedL2toL1Message struct {
	Order   uint64      `json:"order"`
	ToAddr  string      `json:"to_address"`
	Payload []felt.Felt `json:"payload"`
}

type PreConfirmedBlock added in v0.15.0

type PreConfirmedBlock struct {
	Status           string                `json:"status"`
	Transactions     []Transaction         `json:"transactions"`
	Timestamp        uint64                `json:"timestamp"`
	Version          string                `json:"starknet_version"`
	Receipts         []*TransactionReceipt `json:"transaction_receipts"`
	SequencerAddress *felt.Felt            `json:"sequencer_address"`
	L1GasPrice       *GasPrice             `json:"l1_gas_price"`
	L2GasPrice       *GasPrice             `json:"l2_gas_price"`
	L1DAMode         L1DAMode              `json:"l1_da_mode"`
	L1DataGasPrice   *GasPrice             `json:"l1_data_gas_price"`

	TransactionStateDiffs []*StateDiff `json:"transaction_state_diffs"`
}

Block object returned by the feeder in JSON format for "get_preconfirmed_block" endpoint

type Resource added in v0.8.0

type Resource uint32
const (
	ResourceL1Gas Resource = iota + 1
	ResourceL2Gas
	ResourceL1DataGas
)

func (Resource) MarshalText added in v0.8.0

func (r Resource) MarshalText() ([]byte, error)

func (*Resource) UnmarshalJSON added in v0.8.0

func (r *Resource) UnmarshalJSON(data []byte) error

func (*Resource) UnmarshalText added in v0.8.0

func (r *Resource) UnmarshalText(text []byte) error

type ResourceBounds added in v0.8.0

type ResourceBounds struct {
	MaxAmount       *felt.Felt `json:"max_amount"`
	MaxPricePerUnit *felt.Felt `json:"max_price_per_unit"`
}

type SegmentLengths added in v0.11.0

type SegmentLengths struct {
	Children []SegmentLengths
	Length   uint64
}

func (SegmentLengths) MarshalJSON added in v0.11.0

func (n SegmentLengths) MarshalJSON() ([]byte, error)

func (*SegmentLengths) UnmarshalJSON added in v0.11.0

func (n *SegmentLengths) UnmarshalJSON(data []byte) error

type SierraClass added in v0.15.9

type SierraClass struct {
	Abi         string            `json:"abi,omitempty"`
	EntryPoints SierraEntryPoints `json:"entry_points_by_type"`
	Program     []*felt.Felt      `json:"sierra_program"`
	Version     string            `json:"contract_class_version"`
}

type SierraEntryPoint

type SierraEntryPoint struct {
	Index    uint64     `json:"function_idx"`
	Selector *felt.Felt `json:"selector"`
}

type SierraEntryPoints

type SierraEntryPoints struct {
	Constructor []SierraEntryPoint `json:"CONSTRUCTOR"`
	External    []SierraEntryPoint `json:"EXTERNAL"`
	L1Handler   []SierraEntryPoint `json:"L1_HANDLER"`
}

type Signature

type Signature struct {
	BlockNumber    uint64       `json:"block_number"`
	Signature      []*felt.Felt `json:"signature"`
	SignatureInput struct {
		BlockHash           *felt.Felt `json:"block_hash"`
		StateDiffCommitment *felt.Felt `json:"state_diff_commitment"`
	} `json:"signature_input"`
}

Signature object returned by the feeder in JSON format for "get_signature" endpoint

type StateDiff added in v0.15.0

type StateDiff struct {
	// todo(rdr): What is key and value, I think it should go with `felt.StorageKey` and
	//            `felt.StorageValue`. Also, why pointers to values and not values directly
	//             Also, doesn't make complete sense right now why the key is a string instead of
	//             felt.Address
	StorageDiffs map[string][]struct {
		Key   *felt.Felt `json:"key"`
		Value *felt.Felt `json:"value"`
	} `json:"storage_diffs"`

	// todo(rdr): `felt.Nonce` or maybe uint64, it doesn't make sense otherwise
	//             Also, doesn't make complete sense right now why the key is a string instead of
	//             felt.Address
	Nonces map[string]*felt.Felt `json:"nonces"`

	// todo(rdr): change felt.Felt for felt.Address and felt.SierraClassHash. Also, should it be
	//            pointers to values, or values directly
	DeployedContracts []struct {
		Address   *felt.Felt `json:"address"`
		ClassHash *felt.Felt `json:"class_hash"`
	} `json:"deployed_contracts"`

	// v0.11.0
	// todo(rdr): is "old declared contracts" deprecated cairo contracts? We might need a
	//            a `felt.DeprecatedCairoClassHash`
	OldDeclaredContracts []*felt.Felt `json:"old_declared_contracts"`
	// todo(rdr): change the felt here to be `felt.SierraClassHash` and `felt.CasmClassHash`
	DeclaredClasses []struct {
		ClassHash         *felt.Felt `json:"class_hash"`
		CompiledClassHash *felt.Felt `json:"compiled_class_hash"`
	} `json:"declared_classes"`
	// todo(rdr): change the felts here to be `felt.Address` and `felt.SierraClassHash`
	//            but if ClassHash may include other class hashes (deprecated class hashes) then
	//            it is probably better to have `felt.ClassHash`
	ReplacedClasses []struct {
		Address   *felt.Felt `json:"address"`
		ClassHash *felt.Felt `json:"class_hash"`
	} `json:"replaced_classes"`
	MigratedClasses []struct {
		ClassHash         felt.SierraClassHash `json:"class_hash"`
		CompiledClassHash felt.CasmClassHash   `json:"compiled_class_hash"`
	} `json:"migrated_compiled_classes"`
}

type StateUpdate

type StateUpdate struct {
	BlockHash *felt.Felt `json:"block_hash"`
	NewRoot   *felt.Felt `json:"new_root"`
	OldRoot   *felt.Felt `json:"old_root"`
	StateDiff StateDiff  `json:"state_diff"`
}

StateUpdate object returned by the feeder in JSON format for "get_state_update" endpoint

type StateUpdateWithBlock

type StateUpdateWithBlock struct {
	Block       *Block       `json:"block"`
	StateUpdate *StateUpdate `json:"state_update"`
}

StateUpdateWithBlock object returned by the feeder in JSON format for "get_state_update" endpoint with includingBlock arg

type Transaction

type Transaction struct {
	Hash                  *felt.Felt                   `json:"transaction_hash,omitempty"`
	Version               *felt.Felt                   `json:"version,omitempty"`
	ContractAddress       *felt.Felt                   `json:"contract_address,omitempty"`
	ContractAddressSalt   *felt.Felt                   `json:"contract_address_salt,omitempty"`
	ClassHash             *felt.Felt                   `json:"class_hash,omitempty"`
	ConstructorCallData   *[]*felt.Felt                `json:"constructor_calldata,omitempty"`
	Type                  TransactionType              `json:"type,omitempty"`
	SenderAddress         *felt.Felt                   `json:"sender_address,omitempty"`
	MaxFee                *felt.Felt                   `json:"max_fee,omitempty"`
	Signature             *[]*felt.Felt                `json:"signature,omitempty"`
	CallData              *[]*felt.Felt                `json:"calldata,omitempty"`
	EntryPointSelector    *felt.Felt                   `json:"entry_point_selector,omitempty"`
	Nonce                 *felt.Felt                   `json:"nonce,omitempty"`
	CompiledClassHash     *felt.Felt                   `json:"compiled_class_hash,omitempty"`
	ResourceBounds        *map[Resource]ResourceBounds `json:"resource_bounds,omitempty"`
	Tip                   *felt.Felt                   `json:"tip,omitempty"`
	NonceDAMode           *DataAvailabilityMode        `json:"nonce_data_availability_mode,omitempty"`
	FeeDAMode             *DataAvailabilityMode        `json:"fee_data_availability_mode,omitempty"`
	AccountDeploymentData *[]*felt.Felt                `json:"account_deployment_data,omitempty"`
	PaymasterData         *[]*felt.Felt                `json:"paymaster_data,omitempty"`
	ProofFacts            *[]felt.Felt                 `json:"proof_facts,omitempty"`
}

Transaction object returned by the feeder in JSON format for multiple endpoints

type TransactionFailureReason added in v0.15.0

type TransactionFailureReason struct {
	Code    string `json:"code"`
	Message string `json:"error_message"`
}

TransactionFailureReason represents the failure reason of a transaction returned by the feeder.

func (TransactionFailureReason) String added in v0.15.22

func (tf TransactionFailureReason) String() string

String returns the string representation of the TxFailureReason.

type TransactionReceipt

type TransactionReceipt struct {
	ActualFee          *felt.Felt          `json:"actual_fee"`
	Events             []*Event            `json:"events"`
	ExecutionStatus    ExecutionStatus     `json:"execution_status"`
	ExecutionResources *ExecutionResources `json:"execution_resources"`
	L1ToL2Message      *L1ToL2Message      `json:"l1_to_l2_consumed_message"`
	L2ToL1Message      []*L2ToL1Message    `json:"l2_to_l1_messages"`
	TransactionHash    *felt.Felt          `json:"transaction_hash"`
	TransactionIndex   uint64              `json:"transaction_index"`
	RevertError        string              `json:"revert_error"`
}

type TransactionStatus

type TransactionStatus struct {
	TxStatus        string                   `json:"tx_status"`
	FinalityStatus  FinalityStatus           `json:"finality_status"`
	ExecutionStatus ExecutionStatus          `json:"execution_status"`
	BlockHash       *felt.Felt               `json:"block_hash"`
	TxRevertReason  string                   `json:"tx_revert_reason,omitempty"`
	TxFailureReason TransactionFailureReason `json:"tx_failure_reason,omitzero"`
}

TransactionStatus represents the response from the get_transaction_status endpoint.

type TransactionTrace

type TransactionTrace struct {
	TransactionHash       felt.Felt           `json:"transaction_hash"`
	RevertError           string              `json:"revert_error"`
	ValidateInvocation    *FunctionInvocation `json:"validate_invocation"`
	FunctionInvocation    *FunctionInvocation `json:"function_invocation"`
	FeeTransferInvocation *FunctionInvocation `json:"fee_transfer_invocation"`
	Signature             []felt.Felt         `json:"signature"`
}

type TransactionType

type TransactionType uint8
const (
	Invalid TransactionType = iota
	TxnDeclare
	TxnDeploy
	TxnDeployAccount
	TxnInvoke
	TxnL1Handler
)

func (TransactionType) MarshalText added in v0.12.3

func (t TransactionType) MarshalText() ([]byte, error)

func (TransactionType) String

func (t TransactionType) String() string

func (*TransactionType) UnmarshalText added in v0.12.3

func (t *TransactionType) UnmarshalText(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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