rpc

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const ExecutionStepsHeader string = "X-Cairo-Steps"

Variables

View Source
var (
	ErrContractNotFound                = &jsonrpc.Error{Code: 20, Message: "Contract not found"}
	ErrBlockNotFound                   = &jsonrpc.Error{Code: 24, Message: "Block not found"}
	ErrInvalidTxHash                   = &jsonrpc.Error{Code: 25, Message: "Invalid transaction hash"}
	ErrInvalidBlockHash                = &jsonrpc.Error{Code: 26, Message: "Invalid block hash"}
	ErrInvalidTxIndex                  = &jsonrpc.Error{Code: 27, Message: "Invalid transaction index in a block"}
	ErrClassHashNotFound               = &jsonrpc.Error{Code: 28, Message: "Class hash not found"}
	ErrTxnHashNotFound                 = &jsonrpc.Error{Code: 29, Message: "Transaction hash not found"}
	ErrPageSizeTooBig                  = &jsonrpc.Error{Code: 31, Message: "Requested page size is too big"}
	ErrNoBlock                         = &jsonrpc.Error{Code: 32, Message: "There are no blocks"}
	ErrInvalidContinuationToken        = &jsonrpc.Error{Code: 33, Message: "Invalid continuation token"}
	ErrTooManyKeysInFilter             = &jsonrpc.Error{Code: 34, Message: "Too many keys provided in a filter"}
	ErrContractError                   = &jsonrpc.Error{Code: 40, Message: "Contract error"}
	ErrTransactionExecutionError       = &jsonrpc.Error{Code: 41, Message: "Transaction execution error"}
	ErrInvalidContractClass            = &jsonrpc.Error{Code: 50, Message: "Invalid contract class"}
	ErrClassAlreadyDeclared            = &jsonrpc.Error{Code: 51, Message: "Class already declared"}
	ErrInternal                        = &jsonrpc.Error{Code: jsonrpc.InternalError, Message: "Internal error"}
	ErrInvalidTransactionNonce         = &jsonrpc.Error{Code: 52, Message: "Invalid transaction nonce"}
	ErrInsufficientMaxFee              = &jsonrpc.Error{Code: 53, Message: "Max fee is smaller than the minimal transaction cost (validation plus fee transfer)"} //nolint:lll
	ErrInsufficientAccountBalance      = &jsonrpc.Error{Code: 54, Message: "Account balance is smaller than the transaction's max_fee"}
	ErrValidationFailure               = &jsonrpc.Error{Code: 55, Message: "Account validation failed"}
	ErrCompilationFailed               = &jsonrpc.Error{Code: 56, Message: "Compilation failed"}
	ErrContractClassSizeTooLarge       = &jsonrpc.Error{Code: 57, Message: "Contract class size is too large"}
	ErrNonAccount                      = &jsonrpc.Error{Code: 58, Message: "Sender address is not an account contract"}
	ErrDuplicateTx                     = &jsonrpc.Error{Code: 59, Message: "A transaction with the same hash already exists in the mempool"}
	ErrCompiledClassHashMismatch       = &jsonrpc.Error{Code: 60, Message: "the compiled class hash did not match the one supplied in the transaction"} //nolint:lll
	ErrUnsupportedTxVersion            = &jsonrpc.Error{Code: 61, Message: "the transaction version is not supported"}
	ErrUnsupportedContractClassVersion = &jsonrpc.Error{Code: 62, Message: "the contract class version is not supported"}
	ErrUnexpectedError                 = &jsonrpc.Error{Code: 63, Message: "An unexpected error occurred"}

	// These errors can be only be returned by Juno-specific methods.
	ErrSubscriptionNotFound = &jsonrpc.Error{Code: 100, Message: "Subscription not found"}
)

Functions

This section is empty.

Types

type AddTxResponse added in v0.5.0

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

type BlockHashAndNumber added in v0.3.0

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

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

type BlockHeader

type BlockHeader struct {
	Hash             *felt.Felt     `json:"block_hash,omitempty"`
	ParentHash       *felt.Felt     `json:"parent_hash"`
	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       *ResourcePrice `json:"l1_gas_price"`
	L1DataGasPrice   *ResourcePrice `json:"l1_data_gas_price,omitempty"`
	L1DAMode         *L1DAMode      `json:"l1_da_mode,omitempty"`
	StarknetVersion  string         `json:"starknet_version"`
}

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

type BlockID added in v0.2.1

type BlockID struct {
	Pending bool
	Latest  bool
	Hash    *felt.Felt
	Number  uint64
}

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

func (*BlockID) UnmarshalJSON added in v0.2.1

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

type BlockStatus added in v0.5.0

type BlockStatus uint8

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

const (
	BlockPending BlockStatus = iota
	BlockAcceptedL2
	BlockAcceptedL1
	BlockRejected
)

func (BlockStatus) MarshalText added in v0.11.0

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

type BlockWithReceipts added in v0.11.0

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

type BroadcastedTransaction added in v0.4.0

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 Class added in v0.3.0

type Class struct {
	SierraProgram        []*felt.Felt `json:"sierra_program,omitempty"`
	Program              string       `json:"program,omitempty"`
	ContractClassVersion string       `json:"contract_class_version,omitempty"`
	EntryPoints          EntryPoints  `json:"entry_points_by_type"`
	Abi                  any          `json:"abi"`
}

https://github.com/starkware-libs/starknet-specs/blob/e0b76ed0d8d8eba405e182371f9edac8b2bcbc5a/api/starknet_api_openrpc.json#L268-L280

type ComputationResources added in v0.11.0

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 added in v0.8.0

type ContractErrorData struct {
	RevertError string `json:"revert_error"`
}

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
)

func (DataAvailabilityMode) MarshalText added in v0.11.0

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

func (*DataAvailabilityMode) UnmarshalJSON added in v0.8.0

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

type DeclaredClass added in v0.2.1

type DeclaredClass struct {
	ClassHash         felt.Felt `json:"class_hash"`
	CompiledClassHash felt.Felt `json:"compiled_class_hash"`
}

type DeployedContract

type DeployedContract struct {
	Address   felt.Felt `json:"address"`
	ClassHash felt.Felt `json:"class_hash"`
}

type EmittedEvent added in v0.3.1

type EmittedEvent struct {
	*Event
	BlockNumber     *uint64    `json:"block_number,omitempty"`
	BlockHash       *felt.Felt `json:"block_hash,omitempty"`
	TransactionHash *felt.Felt `json:"transaction_hash"`
}

type Entry

type Entry struct {
	Key   felt.Felt `json:"key"`
	Value felt.Felt `json:"value"`
}

type EntryPoint added in v0.3.0

type EntryPoint struct {
	Index    *uint64    `json:"function_idx,omitempty"`
	Offset   *felt.Felt `json:"offset,omitempty"`
	Selector *felt.Felt `json:"selector"`
}

type EntryPoints added in v0.3.0

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,omitempty"`
	Keys []*felt.Felt `json:"keys"`
	Data []*felt.Felt `json:"data"`
}

type EventFilter added in v0.3.1

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

type EventsArg added in v0.3.1

type EventsArg struct {
	EventFilter
	ResultPageRequest
}

type EventsChunk added in v0.3.1

type EventsChunk struct {
	Events            []*EmittedEvent `json:"events"`
	ContinuationToken string          `json:"continuation_token,omitempty"`
}

type ExecutionResources added in v0.7.0

type ExecutionResources struct {
	ComputationResources
	DataAvailability *DataAvailability `json:"data_availability,omitempty"`
}

type FeeEstimate added in v0.4.0

type FeeEstimate struct {
	GasConsumed     *felt.Felt `json:"gas_consumed"`
	GasPrice        *felt.Felt `json:"gas_price"`
	DataGasConsumed *felt.Felt `json:"data_gas_consumed"`
	DataGasPrice    *felt.Felt `json:"data_gas_price"`
	OverallFee      *felt.Felt `json:"overall_fee"`
	Unit            *FeeUnit   `json:"unit,omitempty"`
	// contains filtered or unexported fields
}

func (FeeEstimate) MarshalJSON added in v0.11.0

func (f FeeEstimate) MarshalJSON() ([]byte, error)

type FeePayment added in v0.8.0

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

type FeeUnit added in v0.8.0

type FeeUnit byte
const (
	WEI FeeUnit = iota
	FRI
)

func (FeeUnit) MarshalText added in v0.11.0

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

type FunctionCall added in v0.4.0

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

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

type Gateway added in v0.4.0

type Gateway interface {
	AddTransaction(context.Context, json.RawMessage) (json.RawMessage, error)
}

type Handler

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

func New

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

func (*Handler) AddTransaction added in v0.5.0

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

AddTransaction relays a transaction to the gateway.

func (*Handler) BlockHashAndNumber added in v0.3.0

func (h *Handler) BlockHashAndNumber() (*BlockHashAndNumber, *jsonrpc.Error)

BlockHashAndNumber returns the block hash and number of the latest synced block.

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

func (*Handler) BlockNumber

func (h *Handler) BlockNumber() (uint64, *jsonrpc.Error)

BlockNumber returns the latest synced block number.

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

func (*Handler) BlockTransactionCount added in v0.2.1

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/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L373

func (*Handler) BlockWithReceipts added in v0.11.0

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

func (*Handler) BlockWithTxHashes added in v0.2.1

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/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L11

func (*Handler) BlockWithTxHashesV0_6 added in v0.11.0

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

func (*Handler) BlockWithTxs added in v0.2.1

func (h *Handler) BlockWithTxs(id 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/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L44

func (*Handler) BlockWithTxsV0_6 added in v0.11.0

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

func (*Handler) CallV0_6 added in v0.11.0

func (h *Handler) CallV0_6(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Error)

func (*Handler) ChainID added in v0.2.1

func (h *Handler) ChainID() (*felt.Felt, *jsonrpc.Error)

ChainID returns the chain ID of the currently configured network.

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

func (*Handler) Class added in v0.3.0

func (h *Handler) Class(id BlockID, classHash felt.Felt) (*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/master/api/starknet_api_openrpc.json#L248

func (*Handler) ClassAt added in v0.3.0

func (h *Handler) ClassAt(id BlockID, address felt.Felt) (*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/master/api/starknet_api_openrpc.json#L329

func (*Handler) ClassHashAt added in v0.3.0

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/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L292

func (*Handler) EstimateFee added in v0.4.0

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

func (*Handler) EstimateFeeV0_6 added in v0.11.0

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

func (*Handler) EstimateMessageFee added in v0.5.0

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

func (*Handler) EstimateMessageFeeV0_6 added in v0.11.0

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

func (*Handler) Events added in v0.3.1

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

Events gets the events matching a filter

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

func (*Handler) Methods added in v0.7.0

func (h *Handler) Methods() ([]jsonrpc.Method, string)

func (*Handler) MethodsV0_6 added in v0.11.0

func (h *Handler) MethodsV0_6() ([]jsonrpc.Method, string)

func (*Handler) Nonce added in v0.3.0

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/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_api_openrpc.json#L633

func (*Handler) Run added in v0.7.1

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

func (*Handler) SimulateTransactions added in v0.6.0

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

func (*Handler) SimulateTransactionsV0_6 added in v0.11.0

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

pre 13.1

func (*Handler) SpecVersion added in v0.7.0

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

func (*Handler) SpecVersionV0_6 added in v0.11.0

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

func (*Handler) StateUpdate added in v0.2.1

func (h *Handler) StateUpdate(id BlockID) (*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/master/api/starknet_api_openrpc.json#L77

func (*Handler) StorageAt added in v0.3.0

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) SubscribeNewHeads added in v0.7.1

func (h *Handler) SubscribeNewHeads(ctx context.Context) (uint64, *jsonrpc.Error)

func (*Handler) Syncing added in v0.3.0

func (h *Handler) Syncing() (*Sync, *jsonrpc.Error)

Syncing returns the syncing status of the node.

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

func (*Handler) TraceBlockTransactions added in v0.6.0

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

func (*Handler) TraceBlockTransactionsV0_6 added in v0.11.0

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

func (*Handler) TraceTransaction added in v0.6.0

func (h *Handler) TraceTransaction(ctx context.Context, hash felt.Felt) (*vm.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/1ae810e0137cc5d175ace4554892a4f43052be56/api/starknet_trace_api_openrpc.json#L11

func (*Handler) TraceTransactionV0_6 added in v0.11.0

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

func (*Handler) TransactionByBlockIDAndIndex added in v0.2.1

func (h *Handler) TransactionByBlockIDAndIndex(id 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/master/api/starknet_api_openrpc.json#L184

func (*Handler) TransactionByHash added in v0.2.1

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/master/api/starknet_api_openrpc.json#L158

func (*Handler) TransactionReceiptByHash added in v0.2.1

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) TransactionReceiptByHashV0_6 added in v0.11.0

func (h *Handler) TransactionReceiptByHashV0_6(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 added in v0.4.0

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

func (*Handler) Unsubscribe added in v0.7.1

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

func (*Handler) Version added in v0.4.0

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

func (*Handler) WithCallMaxSteps added in v0.9.3

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

func (*Handler) WithFeeder added in v0.9.3

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

func (*Handler) WithFilterLimit added in v0.7.5

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 added in v0.9.3

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

func (*Handler) WithIDGen added in v0.7.1

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

type L1DAMode added in v0.11.0

type L1DAMode uint8
const (
	Blob L1DAMode = iota
	Calldata
)

func (L1DAMode) MarshalText added in v0.11.0

func (l L1DAMode) MarshalText() ([]byte, error)

type MsgFromL1 added in v0.5.0

type MsgFromL1 struct {
	// The address of the L1 contract sending the message.
	From common.Address `json:"from_address" validate:"required"`
	// The address of the L1 contract sending the message.
	To felt.Felt `json:"to_address" validate:"required"`
	// The payload of the message.
	Payload  []felt.Felt `json:"payload" validate:"required"`
	Selector felt.Felt   `json:"entry_point_selector" validate:"required"`
}

type MsgToL1

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

type Nonce

type Nonce struct {
	ContractAddress felt.Felt `json:"contract_address"`
	Nonce           felt.Felt `json:"nonce"`
}

type ReplacedClass added in v0.2.1

type ReplacedClass struct {
	ContractAddress felt.Felt `json:"contract_address"`
	ClassHash       felt.Felt `json:"class_hash"`
}

type Resource added in v0.8.0

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

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(data []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 ResourcePrice added in v0.7.0

type ResourcePrice struct {
	InFri *felt.Felt `json:"price_in_fri"`
	InWei *felt.Felt `json:"price_in_wei"`
}

type ResultPageRequest added in v0.3.1

type ResultPageRequest struct {
	ContinuationToken string `json:"continuation_token"`
	ChunkSize         uint64 `json:"chunk_size" validate:"min=1"`
}

type SimulatedTransaction added in v0.6.0

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

type SimulationFlag added in v0.6.0

type SimulationFlag int
const (
	SkipValidateFlag SimulationFlag = iota + 1
	SkipFeeChargeFlag
)

func (*SimulationFlag) UnmarshalJSON added in v0.6.0

func (s *SimulationFlag) UnmarshalJSON(bytes []byte) (err error)

type StateDiff

type StateDiff struct {
	StorageDiffs              []StorageDiff      `json:"storage_diffs"`
	Nonces                    []Nonce            `json:"nonces"`
	DeployedContracts         []DeployedContract `json:"deployed_contracts"`
	DeprecatedDeclaredClasses []*felt.Felt       `json:"deprecated_declared_classes"`
	DeclaredClasses           []DeclaredClass    `json:"declared_classes"`
	ReplacedClasses           []ReplacedClass    `json:"replaced_classes"`
}

type StateUpdate

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

https://github.com/starkware-libs/starknet-specs/blob/8016dd08ed7cd220168db16f24c8a6827ab88317/api/starknet_api_openrpc.json#L909

type StorageDiff

type StorageDiff struct {
	Address        felt.Felt `json:"address"`
	StorageEntries []Entry   `json:"storage_entries"`
}

type Sync added in v0.3.0

type Sync struct {
	Syncing             *bool      `json:"-"`
	StartingBlockHash   *felt.Felt `json:"starting_block_hash,omitempty"`
	StartingBlockNumber *uint64    `json:"starting_block_num,omitempty"`
	CurrentBlockHash    *felt.Felt `json:"current_block_hash,omitempty"`
	CurrentBlockNumber  *uint64    `json:"current_block_num,omitempty"`
	HighestBlockHash    *felt.Felt `json:"highest_block_hash,omitempty"`
	HighestBlockNumber  *uint64    `json:"highest_block_num,omitempty"`
}

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

func (Sync) MarshalJSON added in v0.3.0

func (s Sync) MarshalJSON() ([]byte, error)

type TracedBlockTransaction added in v0.6.0

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

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"`
	Nonce                 *felt.Felt                   `json:"nonce,omitempty" validate:"required_unless=Version 0x0"`
	MaxFee                *felt.Felt                   `json:"max_fee,omitempty" validate:"required_if=Version 0x0,required_if=Version 0x1,required_if=Version 0x2"`
	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 Version 0x1"`
	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" validate:"required_if=Type INVOKE Version 0x0"`
	CompiledClassHash     *felt.Felt                   `json:"compiled_class_hash,omitempty" validate:"required_if=Type DECLARE Version 0x2"`
	ResourceBounds        *map[Resource]ResourceBounds `json:"resource_bounds,omitempty" validate:"required_if=Version 0x3"`
	Tip                   *felt.Felt                   `json:"tip,omitempty" validate:"required_if=Version 0x3"`
	PaymasterData         *[]*felt.Felt                `json:"paymaster_data,omitempty" validate:"required_if=Version 0x3"`
	AccountDeploymentData *[]*felt.Felt                `json:"account_deployment_data,omitempty" validate:"required_if=Type INVOKE Version 0x3,required_if=Type DECLARE Version 0x3"`
	NonceDAMode           *DataAvailabilityMode        `json:"nonce_data_availability_mode,omitempty" validate:"required_if=Version 0x3"`
	FeeDAMode             *DataAvailabilityMode        `json:"fee_data_availability_mode,omitempty" validate:"required_if=Version 0x3"`
}

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

func AdaptTransaction added in v0.8.0

func AdaptTransaction(t core.Transaction) *Transaction

type TransactionExecutionErrorData added in v0.8.0

type TransactionExecutionErrorData struct {
	TransactionIndex uint64 `json:"transaction_index"`
	ExecutionError   string `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             []*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 added in v0.11.0

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

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

type TransactionStatus added in v0.5.0

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

type TransactionType

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

func (TransactionType) MarshalText added in v0.11.0

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

func (TransactionType) String added in v0.4.0

func (t TransactionType) String() string

func (*TransactionType) UnmarshalJSON added in v0.4.0

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

type TransactionWithReceipt added in v0.11.0

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

type TxnExecutionStatus added in v0.5.0

type TxnExecutionStatus uint8
const (
	TxnSuccess TxnExecutionStatus = iota + 1
	TxnFailure
)

func (TxnExecutionStatus) MarshalText added in v0.11.0

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

type TxnFinalityStatus added in v0.5.0

type TxnFinalityStatus uint8
const (
	TxnAcceptedOnL1 TxnFinalityStatus = iota + 1
	TxnAcceptedOnL2
)

func (TxnFinalityStatus) MarshalText added in v0.11.0

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

type TxnStatus added in v0.7.2

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

func (TxnStatus) MarshalText added in v0.11.0

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

Jump to

Keyboard shortcuts

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