rpcv9

package
v0.15.13 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MissingContractAddress = "missing field: contract_address"
	MissingStorageKeys     = "missing field: storage_keys"
)
View Source
const ExecutionStepsHeader string = "X-Cairo-Steps"

Variables

View Source
var ErrTransactionNotFound = errors.New("transaction not found")

Functions

func AdaptBroadcastedTransaction

func AdaptBroadcastedTransaction(broadcastedTxn *BroadcastedTransaction,
	network *utils.Network,
) (core.Transaction, core.ClassDefinition, *felt.Felt, error)

func MakeContractError

func MakeContractError(err json.RawMessage) *jsonrpc.Error

func MakeTransactionExecutionError added in v0.15.11

func MakeTransactionExecutionError(err *vm.TransactionExecutionError) *jsonrpc.Error

Types

type AddTxResponse

type AddTxResponse struct {
	TransactionHash *felt.Felt `json:"transaction_hash"`
	ContractAddress *felt.Felt `json:"contract_address,omitempty"`
	ClassHash       *felt.Felt `json:"class_hash,omitempty"`
}

type BinaryNode

type BinaryNode struct {
	Left  *felt.Felt `json:"left"`
	Right *felt.Felt `json:"right"`
}

func (*BinaryNode) AsProofNode

func (b *BinaryNode) AsProofNode() trie.ProofNode

type BlockHeader

type BlockHeader struct {
	Hash             *felt.Felt           `json:"block_hash,omitempty"`
	ParentHash       *felt.Felt           `json:"parent_hash,omitempty"`
	Number           *uint64              `json:"block_number,omitempty"`
	NewRoot          *felt.Felt           `json:"new_root,omitempty"`
	Timestamp        uint64               `json:"timestamp"`
	SequencerAddress *felt.Felt           `json:"sequencer_address,omitempty"`
	L1GasPrice       *rpcv6.ResourcePrice `json:"l1_gas_price"`
	L1DataGasPrice   *rpcv6.ResourcePrice `json:"l1_data_gas_price,omitempty"`
	L1DAMode         *rpcv6.L1DAMode      `json:"l1_da_mode,omitempty"`
	StarknetVersion  string               `json:"starknet_version"`
	L2GasPrice       *rpcv6.ResourcePrice `json:"l2_gas_price"`
}

Allows omitting ParentHash, pre_confirmed block does not have parentHash BLOCK_HEADER https://github.com/starkware-libs/starknet-specs/blob/0bf403bfafbfbe0eaa52103a9c7df545bec8f73b/api/starknet_api_openrpc.json#L1622 PRE_CONFIRMED_BLOCK_HEADER https://github.com/starkware-libs/starknet-specs/blob/0bf403bfafbfbe0eaa52103a9c7df545bec8f73b/api/starknet_api_openrpc.json#L1636

func AdaptBlockHeader added in v0.15.11

func AdaptBlockHeader(header *core.Header) BlockHeader

type BlockID

type BlockID struct {
	// contains filtered or unexported fields
}

https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L814

func BlockIDFromHash

func BlockIDFromHash(blockHash *felt.Felt) BlockID

func BlockIDFromNumber

func BlockIDFromNumber(num uint64) BlockID

func BlockIDL1Accepted added in v0.15.11

func BlockIDL1Accepted() BlockID

func BlockIDLatest added in v0.15.11

func BlockIDLatest() BlockID

func BlockIDPreConfirmed added in v0.15.2

func BlockIDPreConfirmed() BlockID

func (*BlockID) Hash

func (b *BlockID) Hash() *felt.Felt

func (*BlockID) IsHash

func (b *BlockID) IsHash() bool

func (*BlockID) IsL1Accepted added in v0.15.1

func (b *BlockID) IsL1Accepted() bool

func (*BlockID) IsLatest

func (b *BlockID) IsLatest() bool

func (*BlockID) IsNumber

func (b *BlockID) IsNumber() bool

func (*BlockID) IsPreConfirmed

func (b *BlockID) IsPreConfirmed() bool

func (*BlockID) Number

func (b *BlockID) Number() uint64

func (*BlockID) Type

func (b *BlockID) Type() blockIDType

func (*BlockID) UnmarshalJSON

func (b *BlockID) UnmarshalJSON(data []byte) error

type BlockStatus

type BlockStatus uint8

https://github.com/starkware-libs/starknet-specs/blob/fbf8710c2d2dcdb70a95776f257d080392ad0816/api/starknet_api_openrpc.json#L2353-L2363

const (
	BlockPreConfirmed BlockStatus = iota
	BlockAcceptedL2
	BlockAcceptedL1
	BlockRejected
)

func (BlockStatus) MarshalText

func (s BlockStatus) MarshalText() ([]byte, error)

type BlockWithReceipts

type BlockWithReceipts struct {
	Status BlockStatus `json:"status,omitempty"`
	BlockHeader
	Transactions []TransactionWithReceipt `json:"transactions"`
}

type BroadcastedTransaction

type BroadcastedTransaction struct {
	Transaction
	ContractClass json.RawMessage `json:"contract_class,omitempty" validate:"required_if=Transaction.Type DECLARE"`
	PaidFeeOnL1   *felt.Felt      `json:"paid_fee_on_l1,omitempty" validate:"required_if=Transaction.Type L1_HANDLER"`
}

https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L1273-L1287

type BroadcastedTransactionInputs added in v0.15.8

type BroadcastedTransactionInputs = rpccore.LimitSlice[
	BroadcastedTransaction,
	rpccore.SimulationLimit,
]

type CalldataInputs added in v0.15.8

type CompiledCasmResponse added in v0.15.3

type CompiledCasmResponse struct {
	EntryPointsByType EntryPointsByType `json:"entry_points_by_type"`
	// can't use felt.Felt here because prime is larger than felt
	Prime                  string          `json:"prime"`
	CompilerVersion        string          `json:"compiler_version"`
	Bytecode               []*felt.Felt    `json:"bytecode"`
	Hints                  json.RawMessage `json:"hints"`
	BytecodeSegmentLengths []int           `json:"bytecode_segment_lengths,omitempty"`
}

CompiledCasmResponse represents a compiled Cairo class. It follows this specification: https://github.com/starkware-libs/starknet-specs/blob/c2e93098b9c2ca0423b7f4d15b201f52f22d8c36/api/starknet_executables.json#L45

type ComputationResources

type ComputationResources struct {
	Steps        uint64 `json:"steps"`
	MemoryHoles  uint64 `json:"memory_holes,omitempty"`
	Pedersen     uint64 `json:"pedersen_builtin_applications,omitempty"`
	RangeCheck   uint64 `json:"range_check_builtin_applications,omitempty"`
	Bitwise      uint64 `json:"bitwise_builtin_applications,omitempty"`
	Ecsda        uint64 `json:"ecdsa_builtin_applications,omitempty"`
	EcOp         uint64 `json:"ec_op_builtin_applications,omitempty"`
	Keccak       uint64 `json:"keccak_builtin_applications,omitempty"`
	Poseidon     uint64 `json:"poseidon_builtin_applications,omitempty"`
	SegmentArena uint64 `json:"segment_arena_builtin,omitempty"`
}

type ContractErrorData

type ContractErrorData struct {
	RevertError json.RawMessage `json:"revert_error"`
}

type ContractProof

type ContractProof struct {
	Nodes      []*HashToNode `json:"nodes"`
	LeavesData []*LeafData   `json:"contract_leaves_data"`
}

type DataAvailabilityMode

type DataAvailabilityMode uint32
const (
	DAModeL1 DataAvailabilityMode = iota
	DAModeL2
)

func (DataAvailabilityMode) MarshalText

func (m DataAvailabilityMode) MarshalText() ([]byte, error)

func (*DataAvailabilityMode) UnmarshalJSON

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

type EdgeNode

type EdgeNode struct {
	Path   string     `json:"path"`
	Length int        `json:"length"`
	Child  *felt.Felt `json:"child"`
}

func (*EdgeNode) AsProofNode

func (e *EdgeNode) AsProofNode() trie.ProofNode

type EntryPoint added in v0.15.3

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

type EntryPointsByType

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

type EventArgs

type EventArgs struct {
	EventFilter
	rpcv6.ResultPageRequest
}

type EventFilter

type EventFilter struct {
	FromBlock *BlockID      `json:"from_block"`
	ToBlock   *BlockID      `json:"to_block"`
	Address   *felt.Felt    `json:"address"`
	Keys      [][]felt.Felt `json:"keys"`
}

type ExecuteInvocation

type ExecuteInvocation struct {
	RevertReason        string `json:"revert_reason"`
	*FunctionInvocation `json:",omitempty"`
}

func AdaptVMExecuteInvocation added in v0.15.11

func AdaptVMExecuteInvocation(vmFnInvocation *vm.ExecuteInvocation) ExecuteInvocation

func (ExecuteInvocation) MarshalJSON

func (e ExecuteInvocation) MarshalJSON() ([]byte, error)

type ExecutionResources

type ExecutionResources struct {
	InnerExecutionResources
	L1DataGas uint64 `json:"l1_data_gas"`
}

func AdaptVMExecutionResources added in v0.15.11

func AdaptVMExecutionResources(r *vm.ExecutionResources) ExecutionResources

type FeeEstimate

type FeeEstimate struct {
	L1GasConsumed     *felt.Felt `json:"l1_gas_consumed,omitempty"`
	L1GasPrice        *felt.Felt `json:"l1_gas_price,omitempty"`
	L2GasConsumed     *felt.Felt `json:"l2_gas_consumed,omitempty"`
	L2GasPrice        *felt.Felt `json:"l2_gas_price,omitempty"`
	L1DataGasConsumed *felt.Felt `json:"l1_data_gas_consumed,omitempty"`
	L1DataGasPrice    *felt.Felt `json:"l1_data_gas_price,omitempty"`
	OverallFee        *felt.Felt `json:"overall_fee"`
	Unit              *FeeUnit   `json:"unit,omitempty"`
}

type FeePayment

type FeePayment struct {
	Amount *felt.Felt `json:"amount"`
	Unit   FeeUnit    `json:"unit"`
}

type FeeUnit

type FeeUnit byte
const (
	WEI FeeUnit = iota
	FRI
)

func (FeeUnit) MarshalText

func (u FeeUnit) MarshalText() ([]byte, error)

func (*FeeUnit) UnmarshalText added in v0.15.11

func (u *FeeUnit) UnmarshalText(text []byte) error

type FunctionCall

type FunctionCall struct {
	ContractAddress    felt.Felt      `json:"contract_address"`
	EntryPointSelector felt.Felt      `json:"entry_point_selector"`
	Calldata           CalldataInputs `json:"calldata"`
}

https://github.com/starkware-libs/starknet-specs/blob/v0.3.0/api/starknet_api_openrpc.json#L2344

type FunctionInvocation

type FunctionInvocation struct {
	ContractAddress    felt.Felt                    `json:"contract_address"`
	EntryPointSelector *felt.Felt                   `json:"entry_point_selector"`
	Calldata           []felt.Felt                  `json:"calldata"`
	CallerAddress      felt.Felt                    `json:"caller_address"`
	ClassHash          *felt.Felt                   `json:"class_hash"`
	EntryPointType     string                       `json:"entry_point_type"` // todo(rdr): use an enum here
	CallType           string                       `json:"call_type"`        // todo(rdr): use an enum here
	Result             []felt.Felt                  `json:"result"`
	Calls              []FunctionInvocation         `json:"calls"`
	Events             []rpcv6.OrderedEvent         `json:"events"`
	Messages           []rpcv6.OrderedL2toL1Message `json:"messages"`
	ExecutionResources *InnerExecutionResources     `json:"execution_resources"`
	IsReverted         bool                         `json:"is_reverted"`
}

func AdaptFeederFunctionInvocation added in v0.15.11

func AdaptFeederFunctionInvocation(snFnInvocation *starknet.FunctionInvocation) FunctionInvocation

func AdaptVMFunctionInvocation added in v0.15.11

func AdaptVMFunctionInvocation(vmFnInvocation *vm.FunctionInvocation) FunctionInvocation

type GlobalRoots

type GlobalRoots struct {
	ContractsTreeRoot *felt.Felt `json:"contracts_tree_root"`
	ClassesTreeRoot   *felt.Felt `json:"classes_tree_root"`
	BlockHash         *felt.Felt `json:"block_hash"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func New

func New(bcReader blockchain.Reader, syncReader sync.Reader, virtualMachine vm.VM,
	logger utils.Logger,
) *Handler

func (*Handler) AddTransaction

func (h *Handler) AddTransaction(ctx context.Context, tx *BroadcastedTransaction) (AddTxResponse, *jsonrpc.Error)

AddTransaction relays a transaction to the gateway, or to the sequencer if enabled

func (*Handler) BlockTransactionCount

func (h *Handler) BlockTransactionCount(id *BlockID) (uint64, *jsonrpc.Error)

BlockTransactionCount returns the number of transactions in a block identified by the given BlockID.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L548

func (*Handler) BlockWithReceipts

func (h *Handler) BlockWithReceipts(id *BlockID) (*BlockWithReceipts, *jsonrpc.Error)

BlockWithTxHashes returns the block information with transaction receipts given a block ID.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L99

func (*Handler) BlockWithTxHashes

func (h *Handler) BlockWithTxHashes(id *BlockID) (*BlockWithTxHashes, *jsonrpc.Error)

BlockWithTxHashes returns the block information with transaction hashes given a block ID.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L25

func (*Handler) BlockWithTxs

func (h *Handler) BlockWithTxs(blockID *BlockID) (*BlockWithTxs, *jsonrpc.Error)

BlockWithTxs returns the block information with full transactions given a block ID.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L62

func (*Handler) Class

func (h *Handler) Class(id *BlockID, classHash *felt.Felt) (*rpcv6.Class, *jsonrpc.Error)

Class gets the contract class definition in the given block associated with the given hash

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L410

func (*Handler) ClassAt

func (h *Handler) ClassAt(id *BlockID, address *felt.Felt) (*rpcv6.Class, *jsonrpc.Error)

ClassAt gets the contract class definition in the given block instantiated by the given contract address

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L499

func (*Handler) ClassHashAt

func (h *Handler) ClassHashAt(id *BlockID, address *felt.Felt) (*felt.Felt, *jsonrpc.Error)

ClassHashAt gets the class hash for the contract deployed at the given address in the given block.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L459

func (*Handler) CompiledCasm

func (h *Handler) CompiledCasm(classHash *felt.Felt) (CompiledCasmResponse, *jsonrpc.Error)

CompiledCasm receives a class hash and returns the compiled cairo assembly (CASM)

func (*Handler) EstimateFee

func (h *Handler) EstimateFee(
	broadcastedTxns BroadcastedTransactionInputs,
	simulationFlags []rpcv6.SimulationFlag,
	id *BlockID,
) ([]FeeEstimate, http.Header, *jsonrpc.Error)

func (*Handler) EstimateMessageFee

func (h *Handler) EstimateMessageFee(
	msg *rpcv6.MsgFromL1, id *BlockID,
) (FeeEstimate, http.Header, *jsonrpc.Error)

func (*Handler) Events

func (h *Handler) Events(args EventArgs) (rpcv6.EventsChunk, *jsonrpc.Error)

Events gets the events matching a filter

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L813

func (*Handler) GetMessageStatus

func (h *Handler) GetMessageStatus(ctx context.Context, l1TxnHash *common.Hash) ([]MsgStatus, *jsonrpc.Error)

func (*Handler) Nonce

func (h *Handler) Nonce(id *BlockID, address *felt.Felt) (*felt.Felt, *jsonrpc.Error)

Nonce returns the nonce associated with the given address in the given block number

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/25533f8b7999219120a4a654709d47dc9376d640/api/starknet_api_openrpc.json#L851

func (*Handler) PendingBlock

func (h *Handler) PendingBlock() *core.Block

func (*Handler) PendingData

func (h *Handler) PendingData() (core.PendingData, error)

func (*Handler) PendingState

func (h *Handler) PendingState() (core.StateReader, func() error, error)

func (*Handler) Run

func (h *Handler) Run(ctx context.Context) error

Currently only used for testing

func (*Handler) SimulateTransactions

func (h *Handler) SimulateTransactions(
	id *BlockID,
	transactions BroadcastedTransactionInputs,
	simulationFlags []rpcv6.SimulationFlag,
) ([]SimulatedTransaction, http.Header, *jsonrpc.Error)

func (*Handler) SpecVersion

func (h *Handler) SpecVersion() (string, *jsonrpc.Error)

func (*Handler) StateUpdate

func (h *Handler) StateUpdate(id *BlockID) (rpcv6.StateUpdate, *jsonrpc.Error)

StateUpdate returns the state update identified by the given BlockID.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L136

func (*Handler) StorageAt

func (h *Handler) StorageAt(address, key *felt.Felt, id *BlockID) (*felt.Felt, *jsonrpc.Error)

StorageAt gets the value of the storage at the given address and key.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L110

func (*Handler) StorageProof

func (h *Handler) StorageProof(
	id *BlockID, classes, contracts []felt.Felt, storageKeys []StorageKeys,
) (*StorageProofResult, *jsonrpc.Error)

func (*Handler) SubscribeEvents

func (h *Handler) SubscribeEvents(
	ctx context.Context,
	fromAddr *felt.Felt,
	keys [][]felt.Felt,
	blockID *SubscriptionBlockID,
	finalityStatus *TxnFinalityStatusWithoutL1,
) (SubscriptionID, *jsonrpc.Error)

SubscribeEvents creates a WebSocket stream which will fire events for new Starknet events with applied filters

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/c2e93098b9c2ca0423b7f4d15b201f52f22d8c36/api/starknet_ws_api.json#L59

func (*Handler) SubscribeNewHeads

func (h *Handler) SubscribeNewHeads(ctx context.Context, blockID *SubscriptionBlockID) (SubscriptionID, *jsonrpc.Error)

SubscribeNewHeads creates a WebSocket stream which will fire events when a new block header is added.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/c2e93098b9c2ca0423b7f4d15b201f52f22d8c36/api/starknet_ws_api.json#L10

func (*Handler) SubscribeNewTransactionReceipts added in v0.15.2

func (h *Handler) SubscribeNewTransactionReceipts(
	ctx context.Context,
	senderAddress []felt.Felt,
	finalityStatuses []TxnFinalityStatusWithoutL1,
) (SubscriptionID, *jsonrpc.Error)

SubscribeTransactionReceipts creates a WebSocket stream which will fire events when new transaction receipts are created. The endpoint receives a vector of finality statuses. An event is fired for each finality status update. It is possible for receipts for pre-confirmed transactions to be received multiple times, or not at all.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/4e98e3684b50ee9e63b7eeea9412b6a2ed7494ec/api/starknet_ws_api.json#L186

func (*Handler) SubscribeNewTransactions added in v0.15.2

func (h *Handler) SubscribeNewTransactions(
	ctx context.Context,
	finalityStatus []TxnStatusWithoutL1,
	senderAddr []felt.Felt,
) (SubscriptionID, *jsonrpc.Error)

SubscribeNewTransactions Creates a WebSocket stream which will fire events when new transaction are created.

The endpoint receives a vector of finality statuses. An event is fired for each finality status update. It is possible for events for pre-confirmed and candidate transactions to be received multiple times, or not at all.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/4e98e3684b50ee9e63b7eeea9412b6a2ed7494ec/api/starknet_ws_api.json#L257

func (*Handler) SubscribeTransactionStatus

func (h *Handler) SubscribeTransactionStatus(ctx context.Context, txHash *felt.Felt) (SubscriptionID, *jsonrpc.Error)

SubscribeTransactionStatus subscribes to status changes of a transaction. It checks for updates each time a new block is added. Later updates are sent only when the transaction status changes.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/c2e93098b9c2ca0423b7f4d15b201f52f22d8c36/api/starknet_ws_api.json#L151

func (*Handler) TraceBlockTransactions

func (h *Handler) TraceBlockTransactions(
	ctx context.Context, id *BlockID,
) ([]TracedBlockTransaction, http.Header, *jsonrpc.Error)

TraceBlockTransactions returns the trace for a given blockID

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_trace_api_openrpc.json#L108 //nolint:lll

func (*Handler) TraceTransaction

func (h *Handler) TraceTransaction(
	ctx context.Context, hash *felt.Felt,
) (TransactionTrace, http.Header, *jsonrpc.Error)

TraceTransaction returns the trace for a given executed transaction, including internal calls

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_trace_api_openrpc.json#L11

func (*Handler) TransactionByBlockIDAndIndex

func (h *Handler) TransactionByBlockIDAndIndex(
	blockID *BlockID, txIndex int,
) (*Transaction, *jsonrpc.Error)

TransactionByBlockIDAndIndex returns the details of a transaction identified by the given BlockID and index.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/0bf403bfafbfbe0eaa52103a9c7df545bec8f73b/api/starknet_api_openrpc.json#L342

func (*Handler) TransactionByHash

func (h *Handler) TransactionByHash(hash *felt.Felt) (*Transaction, *jsonrpc.Error)

TransactionByHash returns the details of a transaction identified by the given hash.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/0bf403bfafbfbe0eaa52103a9c7df545bec8f73b/api/starknet_api_openrpc.json#L315

func (*Handler) TransactionReceiptByHash

func (h *Handler) TransactionReceiptByHash(hash *felt.Felt) (*TransactionReceipt, *jsonrpc.Error)

TransactionReceiptByHash returns the receipt of a transaction identified by the given hash.

It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L222

func (*Handler) TransactionStatus

func (h *Handler) TransactionStatus(
	ctx context.Context,
	hash *felt.Felt,
) (TransactionStatus, *jsonrpc.Error)

func (*Handler) Unsubscribe

func (h *Handler) Unsubscribe(ctx context.Context, id string) (bool, *jsonrpc.Error)

func (*Handler) WithCallMaxGas added in v0.15.8

func (h *Handler) WithCallMaxGas(maxGas uint64) *Handler

func (*Handler) WithCallMaxSteps

func (h *Handler) WithCallMaxSteps(maxSteps uint64) *Handler

func (*Handler) WithFeeder

func (h *Handler) WithFeeder(feederClient *feeder.Client) *Handler

func (*Handler) WithFilterLimit

func (h *Handler) WithFilterLimit(limit uint) *Handler

WithFilterLimit sets the maximum number of blocks to scan in a single call for event filtering.

func (*Handler) WithGateway

func (h *Handler) WithGateway(gatewayClient rpccore.Gateway) *Handler

func (*Handler) WithIDGen

func (h *Handler) WithIDGen(idgen func() string) *Handler

func (*Handler) WithL1Client

func (h *Handler) WithL1Client(l1Client rpccore.L1Client) *Handler

func (*Handler) WithMempool

func (h *Handler) WithMempool(memPool mempool.Pool) *Handler

func (*Handler) WithSubmittedTransactionsCache

func (h *Handler) WithSubmittedTransactionsCache(cache *rpccore.TransactionCache) *Handler

type HashToNode

type HashToNode struct {
	Hash *felt.Felt `json:"node_hash"`
	Node Node       `json:"node"`
}

type InnerExecutionResources

type InnerExecutionResources struct {
	L1Gas uint64 `json:"l1_gas"`
	L2Gas uint64 `json:"l2_gas"`
}

type LeafData

type LeafData struct {
	Nonce       *felt.Felt `json:"nonce"`
	ClassHash   *felt.Felt `json:"class_hash"`
	StorageRoot *felt.Felt `json:"storage_root"`
}

type MsgStatus

type MsgStatus struct {
	L1HandlerHash   *felt.Felt         `json:"transaction_hash"`
	FinalityStatus  TxnStatus          `json:"finality_status"`
	ExecutionStatus TxnExecutionStatus `json:"execution_status"`
	FailureReason   string             `json:"failure_reason,omitempty"`
}

type MsgToL1

type MsgToL1 struct {
	From    *felt.Felt     `json:"from_address,omitempty"`
	To      common.Address `json:"to_address"`
	Payload []*felt.Felt   `json:"payload"`
}

type Node

type Node interface {
	AsProofNode() trie.ProofNode
}

type ReorgEvent

type ReorgEvent struct {
	StartBlockHash *felt.Felt `json:"starting_block_hash"`
	StartBlockNum  uint64     `json:"starting_block_number"`
	EndBlockHash   *felt.Felt `json:"ending_block_hash"`
	EndBlockNum    uint64     `json:"ending_block_number"`
}

type Resource

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

func (Resource) MarshalText

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

func (*Resource) UnmarshalJSON

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

func (*Resource) UnmarshalText

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

type ResourceBounds

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

type ResourceBoundsMap

type ResourceBoundsMap struct {
	L1Gas     *ResourceBounds `json:"l1_gas" validate:"required"`
	L2Gas     *ResourceBounds `json:"l2_gas" validate:"required"`
	L1DataGas *ResourceBounds `json:"l1_data_gas" validate:"required"`
}

TODO: using Value fields here is a good idea, however we are currently keeping the field's type Reference since the current validation tags we are using does not work well with Value field. We should revisit this when we start implementing custom validations.

func (*ResourceBoundsMap) MarshalJSON

func (r *ResourceBoundsMap) MarshalJSON() ([]byte, error)

type SentEvent

type SentEvent struct {
	TransactionHash felt.Felt
	EventIndex      uint
}

Currently the order of transactions is deterministic, so the transaction always execute on a deterministic state Therefore, the emitted events are deterministic and we can use the transaction hash and event index to identify.

type SentReceipt added in v0.15.2

type SentReceipt struct {
	TransactionHash  felt.Felt
	TransactionIndex int
}

type SimulatedTransaction

type SimulatedTransaction struct {
	TransactionTrace *TransactionTrace `json:"transaction_trace,omitempty"`
	FeeEstimation    FeeEstimate       `json:"fee_estimation,omitzero"`
}

type StorageKeys

type StorageKeys struct {
	Contract *felt.Felt  `json:"contract_address"`
	Keys     []felt.Felt `json:"storage_keys"`
}

type StorageProofResult

type StorageProofResult struct {
	ClassesProof           []*HashToNode   `json:"classes_proof"`
	ContractsProof         *ContractProof  `json:"contracts_proof"`
	ContractsStorageProofs [][]*HashToNode `json:"contracts_storage_proofs"`
	GlobalRoots            *GlobalRoots    `json:"global_roots"`
}

type SubscriptionBlockID

type SubscriptionBlockID BlockID

As per the spec, this is the same as BlockID, but without `pre_confirmed` and `l1_accepted`

func (*SubscriptionBlockID) Hash

func (b *SubscriptionBlockID) Hash() *felt.Felt

func (*SubscriptionBlockID) IsHash

func (b *SubscriptionBlockID) IsHash() bool

func (*SubscriptionBlockID) IsLatest

func (b *SubscriptionBlockID) IsLatest() bool

func (*SubscriptionBlockID) IsNumber

func (b *SubscriptionBlockID) IsNumber() bool

func (*SubscriptionBlockID) Number

func (b *SubscriptionBlockID) Number() uint64

func (*SubscriptionBlockID) Type

func (b *SubscriptionBlockID) Type() blockIDType

func (*SubscriptionBlockID) UnmarshalJSON

func (b *SubscriptionBlockID) UnmarshalJSON(data []byte) error

type SubscriptionEmittedEvent added in v0.15.2

type SubscriptionEmittedEvent struct {
	rpcv6.EmittedEvent
	FinalityStatus TxnFinalityStatus `json:"finality_status"`
}

type SubscriptionID

type SubscriptionID string

type SubscriptionNewTransaction added in v0.15.2

type SubscriptionNewTransaction struct {
	Transaction
	FinalityStatus TxnStatusWithoutL1 `json:"finality_status"`
}

type SubscriptionResponse

type SubscriptionResponse struct {
	Version string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  any    `json:"params"`
}

type SubscriptionTransactionStatus

type SubscriptionTransactionStatus struct {
	TransactionHash *felt.Felt        `json:"transaction_hash"`
	Status          TransactionStatus `json:"status"`
}

type TracedBlockTransaction

type TracedBlockTransaction struct {
	TraceRoot       *TransactionTrace `json:"trace_root,omitempty"`
	TransactionHash *felt.Felt        `json:"transaction_hash,omitempty"`
}

func AdaptFeederBlockTrace

func AdaptFeederBlockTrace(block *BlockWithTxs, blockTrace *starknet.BlockTrace) ([]TracedBlockTransaction, error)

type Transaction

type Transaction struct {
	Hash                  *felt.Felt            `json:"transaction_hash,omitempty"`
	Type                  TransactionType       `json:"type" validate:"required"`
	Version               *felt.Felt            `json:"version,omitempty" validate:"required,version_0x3"`
	Nonce                 *felt.Felt            `json:"nonce,omitempty" validate:"required"`
	MaxFee                *felt.Felt            `json:"max_fee,omitempty"`
	ContractAddress       *felt.Felt            `json:"contract_address,omitempty"`
	ContractAddressSalt   *felt.Felt            `json:"contract_address_salt,omitempty" validate:"required_if=Type DEPLOY,required_if=Type DEPLOY_ACCOUNT"`
	ClassHash             *felt.Felt            `json:"class_hash,omitempty" validate:"required_if=Type DEPLOY,required_if=Type DEPLOY_ACCOUNT"`
	ConstructorCallData   *[]*felt.Felt         `json:"constructor_calldata,omitempty" validate:"required_if=Type DEPLOY,required_if=Type DEPLOY_ACCOUNT"`
	SenderAddress         *felt.Felt            `json:"sender_address,omitempty" validate:"required_if=Type DECLARE,required_if=Type INVOKE"`
	Signature             *[]*felt.Felt         `json:"signature,omitempty" validate:"required"`
	CallData              *[]*felt.Felt         `json:"calldata,omitempty" validate:"required_if=Type INVOKE"`
	EntryPointSelector    *felt.Felt            `json:"entry_point_selector,omitempty"`
	CompiledClassHash     *felt.Felt            `json:"compiled_class_hash,omitempty"`
	ResourceBounds        *ResourceBoundsMap    `json:"resource_bounds,omitempty" validate:"resource_bounds_required"`
	Tip                   *felt.Felt            `json:"tip,omitempty" validate:"required"`
	PaymasterData         *[]*felt.Felt         `json:"paymaster_data,omitempty" validate:"required"`
	AccountDeploymentData *[]*felt.Felt         `json:"account_deployment_data,omitempty" validate:"required_if=Type INVOKE,required_if=Type DECLARE"`
	NonceDAMode           *DataAvailabilityMode `json:"nonce_data_availability_mode,omitempty" validate:"required"`
	FeeDAMode             *DataAvailabilityMode `json:"fee_data_availability_mode,omitempty" validate:"required"`
}

https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L1252

func AdaptTransaction

func AdaptTransaction(t core.Transaction) *Transaction

type TransactionExecutionErrorData

type TransactionExecutionErrorData struct {
	TransactionIndex uint64          `json:"transaction_index"`
	ExecutionError   json.RawMessage `json:"execution_error"`
}

type TransactionReceipt

type TransactionReceipt struct {
	Type               TransactionType     `json:"type"`
	Hash               *felt.Felt          `json:"transaction_hash"`
	ActualFee          *FeePayment         `json:"actual_fee"`
	ExecutionStatus    TxnExecutionStatus  `json:"execution_status"`
	FinalityStatus     TxnFinalityStatus   `json:"finality_status"`
	BlockHash          *felt.Felt          `json:"block_hash,omitempty"`
	BlockNumber        *uint64             `json:"block_number,omitempty"`
	MessagesSent       []*MsgToL1          `json:"messages_sent"`
	Events             []*rpcv6.Event      `json:"events"`
	ContractAddress    *felt.Felt          `json:"contract_address,omitempty"`
	RevertReason       string              `json:"revert_reason,omitempty"`
	ExecutionResources *ExecutionResources `json:"execution_resources,omitempty"`
	MessageHash        string              `json:"message_hash,omitempty"`
}

https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L1871

func AdaptReceipt

func AdaptReceipt(
	receipt *core.TransactionReceipt,
	txn core.Transaction,
	finalityStatus TxnFinalityStatus,
	blockHash *felt.Felt,
	blockNumber uint64,
	isPreLatest bool,
) *TransactionReceipt

todo(Kirill): try to replace core.Transaction with rpc.Transaction type

type TransactionStatus

type TransactionStatus struct {
	Finality      TxnStatus          `json:"finality_status"`
	Execution     TxnExecutionStatus `json:"execution_status,omitempty"`
	FailureReason string             `json:"failure_reason,omitempty"`
}

func AdaptTransactionStatus added in v0.15.11

func AdaptTransactionStatus(txStatus *starknet.TransactionStatus) (TransactionStatus, error)

type TransactionTrace

type TransactionTrace struct {
	Type                  TransactionType     `json:"type"`
	ValidateInvocation    *FunctionInvocation `json:"validate_invocation,omitempty"`
	ExecuteInvocation     *ExecuteInvocation  `json:"execute_invocation,omitempty" validate:"required_if=Type INVOKE"`
	FeeTransferInvocation *FunctionInvocation `json:"fee_transfer_invocation,omitempty"`
	ConstructorInvocation *FunctionInvocation `json:"constructor_invocation,omitempty" validate:"required_if=Type DEPLOY_ACCOUNT"`
	FunctionInvocation    *ExecuteInvocation  `json:"function_invocation,omitempty" validate:"required_if=Type L1_HANDLER"`
	StateDiff             *rpcv6.StateDiff    `json:"state_diff,omitempty"`
	ExecutionResources    *ExecutionResources `json:"execution_resources"`
}

func AdaptVMTransactionTrace

func AdaptVMTransactionTrace(trace *vm.TransactionTrace) TransactionTrace

type TransactionType

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

func (TransactionType) MarshalText

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

func (TransactionType) String

func (t TransactionType) String() string

func (*TransactionType) UnmarshalJSON

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

type TransactionWithReceipt

type TransactionWithReceipt struct {
	Transaction *Transaction        `json:"transaction"`
	Receipt     *TransactionReceipt `json:"receipt"`
}

type TxnExecutionStatus

type TxnExecutionStatus uint8
const (
	UnknownExecution TxnExecutionStatus = iota
	TxnSuccess
	TxnFailure
)

func (TxnExecutionStatus) MarshalText

func (es TxnExecutionStatus) MarshalText() ([]byte, error)

func (*TxnExecutionStatus) UnmarshalText added in v0.15.11

func (es *TxnExecutionStatus) UnmarshalText(text []byte) error

type TxnFinalityStatus

type TxnFinalityStatus uint8

https://github.com/starkware-libs/starknet-specs/blob/9377851884da5c81f757b6ae0ed47e84f9e7c058/api/starknet_api_openrpc.json#L3134

const (
	// Starts from 3 for TxnFinalityStatuses to match same numbers on TxnStatus
	TxnPreConfirmed TxnFinalityStatus = iota + 3
	TxnAcceptedOnL2
	TxnAcceptedOnL1
)

func (TxnFinalityStatus) MarshalText

func (fs TxnFinalityStatus) MarshalText() ([]byte, error)

func (*TxnFinalityStatus) UnmarshalText added in v0.15.11

func (fs *TxnFinalityStatus) UnmarshalText(text []byte) error

type TxnFinalityStatusWithoutL1 added in v0.15.2

type TxnFinalityStatusWithoutL1 TxnFinalityStatus

func (TxnFinalityStatusWithoutL1) MarshalText added in v0.15.2

func (s TxnFinalityStatusWithoutL1) MarshalText() ([]byte, error)

func (*TxnFinalityStatusWithoutL1) UnmarshalText added in v0.15.2

func (s *TxnFinalityStatusWithoutL1) UnmarshalText(text []byte) error

type TxnStatus

type TxnStatus uint8
const (
	TxnStatusReceived TxnStatus = iota + 1
	TxnStatusCandidate
	TxnStatusPreConfirmed
	TxnStatusAcceptedOnL2
	TxnStatusAcceptedOnL1
)

func (TxnStatus) MarshalText

func (s TxnStatus) MarshalText() ([]byte, error)

type TxnStatusWithoutL1 added in v0.15.2

type TxnStatusWithoutL1 TxnStatus

func (TxnStatusWithoutL1) MarshalText added in v0.15.2

func (s TxnStatusWithoutL1) MarshalText() ([]byte, error)

func (*TxnStatusWithoutL1) UnmarshalText added in v0.15.2

func (s *TxnStatusWithoutL1) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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