Documentation
¶
Index ¶
- Variables
- type AddInvokeTxResponse
- type BlockHashAndNumber
- type BlockHeader
- type BlockID
- type BlockWithTxHashes
- type BlockWithTxs
- type BroadcastedTransaction
- type Class
- type DeclareTxResponse
- type DeclaredClass
- type DeployAccountTxResponse
- type DeployedContract
- type EmittedEvent
- type Entry
- type EntryPoint
- type EntryPoints
- type Event
- type EventFilter
- type EventsArg
- type EventsChunk
- type FeeEstimate
- type FunctionCall
- type Gateway
- type Handler
- func (h *Handler) AddDeclareTransaction(declareTx json.RawMessage) (*DeclareTxResponse, *jsonrpc.Error)
- func (h *Handler) AddDeployAccountTransaction(deployAcntTx json.RawMessage) (*DeployAccountTxResponse, *jsonrpc.Error)
- func (h *Handler) AddInvokeTransaction(invokeTx json.RawMessage) (*AddInvokeTxResponse, *jsonrpc.Error)
- func (h *Handler) BlockHashAndNumber() (*BlockHashAndNumber, *jsonrpc.Error)
- func (h *Handler) BlockNumber() (uint64, *jsonrpc.Error)
- func (h *Handler) BlockTransactionCount(id BlockID) (uint64, *jsonrpc.Error)
- func (h *Handler) BlockWithTxHashes(id BlockID) (*BlockWithTxHashes, *jsonrpc.Error)
- func (h *Handler) BlockWithTxs(id BlockID) (*BlockWithTxs, *jsonrpc.Error)
- func (h *Handler) Call(call FunctionCall, id BlockID) ([]*felt.Felt, *jsonrpc.Error)
- func (h *Handler) ChainID() (*felt.Felt, *jsonrpc.Error)
- func (h *Handler) Class(id BlockID, classHash felt.Felt) (*Class, *jsonrpc.Error)
- func (h *Handler) ClassAt(id BlockID, address felt.Felt) (*Class, *jsonrpc.Error)
- func (h *Handler) ClassHashAt(id BlockID, address felt.Felt) (*felt.Felt, *jsonrpc.Error)
- func (h *Handler) EstimateFee(broadcastedTxns []BroadcastedTransaction, id BlockID) ([]FeeEstimate, *jsonrpc.Error)
- func (h *Handler) Events(args EventsArg) (*EventsChunk, *jsonrpc.Error)
- func (h *Handler) Nonce(id BlockID, address felt.Felt) (*felt.Felt, *jsonrpc.Error)
- func (h *Handler) PendingTransactions() ([]*Transaction, *jsonrpc.Error)
- func (h *Handler) StateUpdate(id BlockID) (*StateUpdate, *jsonrpc.Error)
- func (h *Handler) StorageAt(address, key felt.Felt, id BlockID) (*felt.Felt, *jsonrpc.Error)
- func (h *Handler) Syncing() (*Sync, *jsonrpc.Error)
- func (h *Handler) TransactionByBlockIDAndIndex(id BlockID, txIndex int) (*Transaction, *jsonrpc.Error)
- func (h *Handler) TransactionByHash(hash felt.Felt) (*Transaction, *jsonrpc.Error)
- func (h *Handler) TransactionReceiptByHash(hash felt.Felt) (*TransactionReceipt, *jsonrpc.Error)
- func (h *Handler) TransactionStatus(hash felt.Felt) (Status, *jsonrpc.Error)
- func (h *Handler) Version() (string, *jsonrpc.Error)
- type MsgToL1
- type Nonce
- type NumAsHex
- type ReplacedClass
- type ResultPageRequest
- type StateDiff
- type StateUpdate
- type Status
- type StorageDiff
- type Sync
- type Transaction
- type TransactionReceipt
- type TransactionType
Constants ¶
This section is empty.
Variables ¶
var ( ErrBlockNotFound = &jsonrpc.Error{Code: 24, Message: "Block not found"} ErrContractNotFound = &jsonrpc.Error{Code: 20, Message: "Contract not found"} ErrTxnHashNotFound = &jsonrpc.Error{Code: 25, Message: "Transaction hash not found"} ErrNoBlock = &jsonrpc.Error{Code: 32, Message: "There are no blocks"} ErrInvalidTxIndex = &jsonrpc.Error{Code: 27, Message: "Invalid transaction index in a block"} ErrClassHashNotFound = &jsonrpc.Error{Code: 28, Message: "Class hash not found"} ErrInvalidContinuationToken = &jsonrpc.Error{Code: 33, Message: "Invalid continuation token"} ErrPageSizeTooBig = &jsonrpc.Error{Code: 31, Message: "Requested page size is too big"} ErrTooManyKeysInFilter = &jsonrpc.Error{Code: 34, Message: "Too many keys provided in a filter"} ErrInvlaidContractClass = &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"} ErrContractError = &jsonrpc.Error{Code: 40, Message: "Contract error"} )
Functions ¶
This section is empty.
Types ¶
type AddInvokeTxResponse ¶ added in v0.4.0
type BlockHashAndNumber ¶ added in v0.3.0
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"`
}
type BlockID ¶ added in v0.2.1
func (*BlockID) UnmarshalJSON ¶ added in v0.2.1
type BlockWithTxHashes ¶
type BlockWithTxHashes struct {
Status Status `json:"status"`
BlockHeader
TxnHashes []*felt.Felt `json:"transactions"`
}
type BlockWithTxs ¶
type BlockWithTxs struct {
Status Status `json:"status"`
BlockHeader
Transactions []*Transaction `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"`
}
type Class ¶ added in v0.3.0
type DeclareTxResponse ¶ added in v0.4.0
type DeclaredClass ¶ added in v0.2.1
type DeployAccountTxResponse ¶ added in v0.4.0
type DeployedContract ¶
type EmittedEvent ¶ added in v0.3.1
type EntryPoint ¶ added in v0.3.0
type EntryPoints ¶ added in v0.3.0
type EntryPoints struct {
Constructor []EntryPoint `json:"CONSTRUCTOR"`
External []EntryPoint `json:"EXTERNAL"`
L1Handler []EntryPoint `json:"L1_HANDLER"`
}
type EventFilter ¶ added in v0.3.1
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 FeeEstimate ¶ added in v0.4.0
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(json.RawMessage) (json.RawMessage, error)
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) AddDeclareTransaction ¶ added in v0.4.0
func (h *Handler) AddDeclareTransaction(declareTx json.RawMessage) (*DeclareTxResponse, *jsonrpc.Error)
AddDeclareTransaction relays a declare transaction to the gateway.
It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_write_api.json#L39 Note: The gateway expects the sierra_program to be gzip compressed and 64-base encoded. We perform this operation, and then relay the transaction to the gateway.
func (*Handler) AddDeployAccountTransaction ¶ added in v0.4.0
func (h *Handler) AddDeployAccountTransaction(deployAcntTx json.RawMessage) (*DeployAccountTxResponse, *jsonrpc.Error)
AddDeployAccountTransaction relays an deploy account transaction to the gateway.
It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_write_api.json#L74 Note: This handler is a proxy. No checks are performed on the incoming request since we rely on the gateway to perform sanity checks. Any error returned by the gateway is returned to the user as a jsonrpc error.
func (*Handler) AddInvokeTransaction ¶ added in v0.4.0
func (h *Handler) AddInvokeTransaction(invokeTx json.RawMessage) (*AddInvokeTxResponse, *jsonrpc.Error)
AddInvokeTransaction relays an invoke transaction to the gateway.
It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/a789ccc3432c57777beceaa53a34a7ae2f25fda0/api/starknet_write_api.json#L11 Note: No checks are performed on the incoming request since we rely on the gateway to perform sanity checks. As this handler is just as a proxy. Any error returned by the gateway is returned to the user as a jsonrpc error.
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 ¶
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
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) 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) 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) ChainID ¶ added in v0.2.1
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
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
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
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, id BlockID) ([]FeeEstimate, *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) Nonce ¶ added in v0.3.0
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) PendingTransactions ¶ added in v0.4.0
func (h *Handler) PendingTransactions() ([]*Transaction, *jsonrpc.Error)
PendingTransactions gets the transactions in the pending block
It follows the specification defined here: https://github.com/starkware-libs/starknet-specs/blob/aaea417f193bbec87b59455128d4b09a06876c28/api/starknet_api_openrpc.json#L602-L616
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
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) Syncing ¶ added in v0.3.0
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) 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
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
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
type ReplacedClass ¶ added in v0.2.1
type ResultPageRequest ¶ added in v0.3.1
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 Status ¶
type Status uint8
func (Status) MarshalJSON ¶
func (*Status) UnmarshalJSON ¶ added in v0.4.0
type StorageDiff ¶
type Sync ¶ added in v0.3.0
type Sync struct {
Syncing *bool `json:"-"`
StartingBlockHash *felt.Felt `json:"starting_block_hash,omitempty"`
StartingBlockNumber *NumAsHex `json:"starting_block_num,omitempty"`
CurrentBlockHash *felt.Felt `json:"current_block_hash,omitempty"`
CurrentBlockNumber *NumAsHex `json:"current_block_num,omitempty"`
HighestBlockHash *felt.Felt `json:"highest_block_hash,omitempty"`
HighestBlockNumber *NumAsHex `json:"highest_block_num,omitempty"`
}
func (Sync) MarshalJSON ¶ added in v0.3.0
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"`
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"`
}
type TransactionReceipt ¶
type TransactionReceipt struct {
Type TransactionType `json:"type"`
Hash *felt.Felt `json:"transaction_hash"`
ActualFee *felt.Felt `json:"actual_fee"`
Status Status `json:"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"`
}
https://github.com/starkware-libs/starknet-specs/blob/master/api/starknet_api_openrpc.json#L1871
type TransactionType ¶
type TransactionType uint8
const ( Invalid TransactionType = iota TxnDeclare TxnDeploy TxnDeployAccount TxnInvoke TxnL1Handler )
func (TransactionType) MarshalJSON ¶
func (t TransactionType) MarshalJSON() ([]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