Documentation
¶
Index ¶
- Constants
- Variables
- func NewClient(url string) (*client.Client, error)
- type AddDeclareTransactionOutput
- type AddDeclareTransactionResponse
- type AddDeclareTxnInput
- type AddDeployAccountTransactionResponse
- type AddInvokeTransactionResponse
- type BinaryNode
- type Block
- type BlockBodyWithReceipts
- type BlockDeclareTxnV0
- type BlockDeclareTxnV1
- type BlockDeclareTxnV2
- type BlockDeclareTxnV3
- type BlockDeployAccountTxn
- type BlockDeployTxn
- type BlockHashAndNumberOutput
- type BlockHeader
- type BlockID
- type BlockInvokeTxnV0
- type BlockInvokeTxnV1
- type BlockInvokeTxnV3
- type BlockL1HandlerTxn
- type BlockStatus
- type BlockTransaction
- type BlockTransactions
- type BlockTxHashes
- type BlockWithReceipts
- type BroadcastDeclareTxnV3
- type BroadcastDeployAccountTxnV3
- type BroadcastInvokeTxnV3
- type BroadcastTxn
- type CallType
- type ClassOutput
- type CompilationErrData
- type ContractErrData
- type ContractExecutionError
- type ContractExecutionErrorInner
- type ContractLeavesData
- type ContractNonce
- type ContractStorageDiffItem
- type ContractStorageKeys
- type ContractsProof
- type DataAvailabilityMode
- type DeclareTxnTrace
- type DeclareTxnType
- type DeclareTxnV0
- type DeclareTxnV1
- type DeclareTxnV2
- type DeclareTxnV3
- type DeclaredClassesItem
- type DeployAccountTxn
- type DeployAccountTxnTrace
- type DeployAccountTxnV3
- type DeployAccountType
- type DeployTxn
- type DeployedContractItem
- type EdgeNode
- type EmittedEvent
- type EntryPointType
- type Event
- type EventChunk
- type EventContent
- type EventFilter
- type EventSubscriptionInput
- type EventsInput
- type ExecInvocation
- type ExecutionResources
- type FeeEstimation
- type FeePayment
- type FeePaymentUnit
- type FnInvocation
- type FunctionCall
- type GlobalRoots
- type IBlockTransaction
- type InnerCallExecutionResources
- type InvokeFunctionCall
- type InvokeTxnTrace
- type InvokeTxnType
- type InvokeTxnV0
- type InvokeTxnV1
- type InvokeTxnV3
- type L1DAMode
- type L1HandlerTxn
- type L1HandlerTxnTrace
- type L1HandlerTxnVersion
- type MerkleNode
- type MessageStatusResp
- type MsgFromL1
- type MsgToL1
- type NewTxnStatusResp
- type NodeHashToNode
- type NumAsHex
- type OrderedEvent
- type OrderedMsg
- type PendingBlock
- type PendingBlockHeader
- type PendingBlockTxHashes
- type PendingBlockWithReceipts
- type PendingStateUpdate
- type Provider
- func (provider *Provider) AddDeclareTransaction(ctx context.Context, declareTransaction *BroadcastDeclareTxnV3) (*AddDeclareTransactionResponse, error)
- func (provider *Provider) AddDeployAccountTransaction(ctx context.Context, deployAccountTransaction *BroadcastDeployAccountTxnV3) (*AddDeployAccountTransactionResponse, error)
- func (provider *Provider) AddInvokeTransaction(ctx context.Context, invokeTxn *BroadcastInvokeTxnV3) (*AddInvokeTransactionResponse, error)
- func (provider *Provider) BlockHashAndNumber(ctx context.Context) (*BlockHashAndNumberOutput, error)
- func (provider *Provider) BlockNumber(ctx context.Context) (uint64, error)
- func (provider *Provider) BlockTransactionCount(ctx context.Context, blockID BlockID) (uint64, error)
- func (provider *Provider) BlockWithReceipts(ctx context.Context, blockID BlockID) (interface{}, error)
- func (provider *Provider) BlockWithTxHashes(ctx context.Context, blockID BlockID) (interface{}, error)
- func (provider *Provider) BlockWithTxs(ctx context.Context, blockID BlockID) (interface{}, error)
- func (provider *Provider) Call(ctx context.Context, request FunctionCall, blockID BlockID) ([]*felt.Felt, error)
- func (provider *Provider) ChainID(ctx context.Context) (string, error)
- func (provider *Provider) Class(ctx context.Context, blockID BlockID, classHash *felt.Felt) (ClassOutput, error)
- func (provider *Provider) ClassAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (ClassOutput, error)
- func (provider *Provider) ClassHashAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
- func (provider *Provider) CompiledCasm(ctx context.Context, classHash *felt.Felt) (*contracts.CasmClass, error)
- func (provider *Provider) EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, ...) ([]FeeEstimation, error)
- func (provider *Provider) EstimateMessageFee(ctx context.Context, msg MsgFromL1, blockID BlockID) (*FeeEstimation, error)
- func (provider *Provider) Events(ctx context.Context, input EventsInput) (*EventChunk, error)
- func (provider *Provider) GetMessagesStatus(ctx context.Context, transactionHash NumAsHex) ([]MessageStatusResp, error)
- func (provider *Provider) GetStorageProof(ctx context.Context, storageProofInput StorageProofInput) (*StorageProofResult, error)
- func (provider *Provider) GetTransactionStatus(ctx context.Context, transactionHash *felt.Felt) (*TxnStatusResp, error)
- func (provider *Provider) Nonce(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
- func (provider *Provider) SimulateTransactions(ctx context.Context, blockID BlockID, txns []BroadcastTxn, ...) ([]SimulatedTransaction, error)
- func (provider *Provider) SpecVersion(ctx context.Context) (string, error)
- func (provider *Provider) StateUpdate(ctx context.Context, blockID BlockID) (*StateUpdateOutput, error)
- func (provider *Provider) StorageAt(ctx context.Context, contractAddress *felt.Felt, key string, blockID BlockID) (string, error)
- func (provider *Provider) Syncing(ctx context.Context) (*SyncStatus, error)
- func (provider *Provider) TraceBlockTransactions(ctx context.Context, blockID BlockID) ([]Trace, error)
- func (provider *Provider) TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error)
- func (provider *Provider) TransactionByBlockIdAndIndex(ctx context.Context, blockID BlockID, index uint64) (*BlockTransaction, error)
- func (provider *Provider) TransactionByHash(ctx context.Context, hash *felt.Felt) (*BlockTransaction, error)
- func (provider *Provider) TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (*TransactionReceiptWithBlockInfo, error)
- type RPCData
- type RPCError
- type ReplacedClassesItem
- type Resource
- type ResourceBounds
- type ResourceBoundsMapping
- type ResourcePrice
- type ResultPageRequest
- type RpcProvider
- type SimulateTransactionInput
- type SimulatedTransaction
- type SimulationFlag
- type StateDiff
- type StateUpdateOutput
- type StorageEntry
- type StorageProofInput
- type StorageProofResult
- type StringErrData
- type SubPendingTxns
- type SubPendingTxnsInput
- type SyncStatus
- type TXN
- type Trace
- type TraceStatus
- type TraceStatusErrData
- type Transaction
- type TransactionExecErrData
- type TransactionReceipt
- type TransactionReceiptWithBlockInfo
- type TransactionResponse
- type TransactionType
- type TransactionVersion
- type TransactionWithReceipt
- type TxDetails
- type TxnExecutionStatus
- type TxnFinalityStatus
- type TxnStatus
- type TxnStatusResp
- type TxnTrace
- type U128
- type U64
- type UnknownTransaction
- type WebsocketProvider
- type WsProvider
- func (p *WsProvider) Close()
- func (provider *WsProvider) SubscribeEvents(ctx context.Context, events chan<- *EmittedEvent, ...) (*client.ClientSubscription, error)
- func (provider *WsProvider) SubscribeNewHeads(ctx context.Context, headers chan<- *BlockHeader, blockID BlockID) (*client.ClientSubscription, error)
- func (provider *WsProvider) SubscribePendingTransactions(ctx context.Context, pendingTxns chan<- *SubPendingTxns, ...) (*client.ClientSubscription, error)
- func (provider *WsProvider) SubscribeTransactionStatus(ctx context.Context, newStatus chan<- *NewTxnStatusResp, ...) (*client.ClientSubscription, error)
Constants ¶
const ( InvalidJSON = -32700 // Invalid JSON was received by the server. InvalidRequest = -32600 // The JSON sent is not a valid Request object. MethodNotFound = -32601 // The method does not exist / is not available. InvalidParams = -32602 // Invalid method parameter(s). InternalError = -32603 // Internal JSON-RPC error. )
Variables ¶
var ( ErrFailedToReceiveTxn = &RPCError{ Code: 1, Message: "Failed to write transaction", } ErrNoTraceAvailable = &RPCError{ Code: 10, Message: "No trace available for transaction", Data: &TraceStatusErrData{}, } ErrContractNotFound = &RPCError{ Code: 20, Message: "Contract not found", } ErrEntrypointNotFound = &RPCError{ Code: 21, Message: "Requested entrypoint does not exist in the contract", } ErrBlockNotFound = &RPCError{ Code: 24, Message: "Block not found", } ErrInvalidTxnHash = &RPCError{ Code: 25, Message: "Invalid transaction hash", } ErrInvalidBlockHash = &RPCError{ Code: 26, Message: "Invalid block hash", } ErrInvalidTxnIndex = &RPCError{ Code: 27, Message: "Invalid transaction index in a block", } ErrClassHashNotFound = &RPCError{ Code: 28, Message: "Class hash not found", } ErrHashNotFound = &RPCError{ Code: 29, Message: "Transaction hash not found", } ErrPageSizeTooBig = &RPCError{ Code: 31, Message: "Requested page size is too big", } ErrNoBlocks = &RPCError{ Code: 32, Message: "There are no blocks", } ErrInvalidContinuationToken = &RPCError{ Code: 33, Message: "The supplied continuation token is invalid or unknown", } ErrTooManyKeysInFilter = &RPCError{ Code: 34, Message: "Too many keys provided in a filter", } ErrContractError = &RPCError{ Code: 40, Message: "Contract error", Data: &ContractErrData{}, } ErrTxnExec = &RPCError{ Code: 41, Message: "Transaction execution error", Data: &TransactionExecErrData{}, } ErrStorageProofNotSupported = &RPCError{ Code: 42, Message: "the node doesn't support storage proofs for blocks that are too far in the past", } ErrInvalidContractClass = &RPCError{ Code: 50, Message: "Invalid contract class", } ErrClassAlreadyDeclared = &RPCError{ Code: 51, Message: "Class already declared", } ErrInvalidTransactionNonce = &RPCError{ Code: 52, Message: "Invalid transaction nonce", } ErrInsufficientResourcesForValidate = &RPCError{ Code: 53, Message: "The transaction's resources don't cover validation or the minimal transaction fee", } ErrInsufficientAccountBalance = &RPCError{ Code: 54, Message: "Account balance is smaller than the transaction's maximal fee (calculated as the sum of each resource's limit x max price)", } ErrValidationFailure = &RPCError{ Code: 55, Message: "Account validation failed", Data: StringErrData(""), } ErrCompilationFailed = &RPCError{ Code: 56, Message: "Compilation failed", Data: StringErrData(""), } ErrContractClassSizeTooLarge = &RPCError{ Code: 57, Message: "Contract class size is too large", } ErrNonAccount = &RPCError{ Code: 58, Message: "Sender address is not an account contract", } ErrDuplicateTx = &RPCError{ Code: 59, Message: "A transaction with the same hash already exists in the mempool", } ErrCompiledClassHashMismatch = &RPCError{ Code: 60, Message: "The compiled class hash did not match the one supplied in the transaction", } ErrUnsupportedTxVersion = &RPCError{ Code: 61, Message: "The transaction version is not supported", } ErrUnsupportedContractClassVersion = &RPCError{ Code: 62, Message: "The contract class version is not supported", } ErrUnexpectedError = &RPCError{ Code: 63, Message: "An unexpected error occurred", Data: StringErrData(""), } ErrInvalidSubscriptionID = &RPCError{ Code: 66, Message: "Invalid subscription id", } ErrTooManyAddressesInFilter = &RPCError{ Code: 67, Message: "Too many addresses in filter sender_address filter", } ErrTooManyBlocksBack = &RPCError{ Code: 68, Message: "Cannot go back more than 1024 blocks", } ErrCompilationError = &RPCError{ Code: 100, Message: "Failed to compile the contract", Data: &CompilationErrData{}, } )
var ErrInvalidBlockID = errors.New("invalid blockid")
Functions ¶
Types ¶
type AddDeclareTransactionOutput ¶
type AddDeclareTransactionOutput struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
ClassHash *felt.Felt `json:"class_hash"`
}
AddDeclareTransactionOutput provides the output for AddDeclareTransaction.
type AddDeclareTransactionResponse ¶
type AddDeclareTransactionResponse struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
ClassHash *felt.Felt `json:"class_hash"`
}
AddDeclareTransactionResponse provides the output for AddDeclareTransaction.
type AddDeclareTxnInput ¶ added in v0.4.4
type AddDeclareTxnInput interface{}
type AddDeployAccountTransactionResponse ¶ added in v0.4.3
type AddDeployAccountTransactionResponse struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
ContractAddress *felt.Felt `json:"contract_address"`
}
AddDeployTransactionResponse provides the output for AddDeployTransaction.
type AddInvokeTransactionResponse ¶
AddInvokeTransactionResponse provides the output for AddInvokeTransaction.
type BinaryNode ¶ added in v0.8.0
type BinaryNode struct {
// the hash of the left child
Left *felt.Felt `json:"left"`
// the hash of the right child
Right *felt.Felt `json:"right"`
}
An internal node whose both children are non-zero
type Block ¶
type Block struct {
BlockHeader
Status BlockStatus `json:"status"`
// Transactions The transactions in this block
Transactions BlockTransactions `json:"transactions"`
}
type BlockBodyWithReceipts ¶ added in v0.7.0
type BlockBodyWithReceipts struct {
Transactions []TransactionWithReceipt `json:"transactions"`
}
type BlockDeclareTxnV0 ¶ added in v0.4.4
type BlockDeclareTxnV0 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
DeclareTxnV0
}
func (BlockDeclareTxnV0) Hash ¶ added in v0.4.4
func (tx BlockDeclareTxnV0) Hash() *felt.Felt
Hash returns the transaction hash of the BlockDeclareTxnV0.
type BlockDeclareTxnV1 ¶ added in v0.4.4
type BlockDeclareTxnV1 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
DeclareTxnV1
}
func (BlockDeclareTxnV1) Hash ¶ added in v0.4.4
func (tx BlockDeclareTxnV1) Hash() *felt.Felt
Hash returns the transaction hash of the BlockDeclareTxnV1.
type BlockDeclareTxnV2 ¶ added in v0.4.4
type BlockDeclareTxnV2 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
DeclareTxnV2
}
func (BlockDeclareTxnV2) Hash ¶ added in v0.4.4
func (tx BlockDeclareTxnV2) Hash() *felt.Felt
Hash returns the transaction hash of the BlockDeclareTxnV2.
type BlockDeclareTxnV3 ¶ added in v0.7.1
type BlockDeclareTxnV3 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
DeclareTxnV3
}
func (BlockDeclareTxnV3) Hash ¶ added in v0.7.1
func (tx BlockDeclareTxnV3) Hash() *felt.Felt
Hash returns the transaction hash of the BlockDeclareTxnV3.
type BlockDeployAccountTxn ¶ added in v0.4.4
type BlockDeployAccountTxn struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
DeployAccountTxn
}
func (BlockDeployAccountTxn) Hash ¶ added in v0.4.4
func (tx BlockDeployAccountTxn) Hash() *felt.Felt
Hash returns the Felt hash of the BlockDeployAccountTxn.
type BlockDeployTxn ¶ added in v0.4.4
func (BlockDeployTxn) Hash ¶ added in v0.4.4
func (tx BlockDeployTxn) Hash() *felt.Felt
Hash returns the hash of the BlockDeployTxn.
type BlockHashAndNumberOutput ¶
type BlockHashAndNumberOutput struct {
BlockNumber uint64 `json:"block_number,omitempty"`
BlockHash *felt.Felt `json:"block_hash,omitempty"`
}
BlockHashAndNumberOutput is a struct that is returned by BlockHashAndNumber.
type BlockHeader ¶
type BlockHeader struct {
// BlockHash The hash of this block
BlockHash *felt.Felt `json:"block_hash"`
// ParentHash The hash of this block's parent
ParentHash *felt.Felt `json:"parent_hash"`
// BlockNumber the block number (its height)
BlockNumber uint64 `json:"block_number"`
// NewRoot The new global state root
NewRoot *felt.Felt `json:"new_root"`
// Timestamp the time in which the block was created, encoded in Unix time
Timestamp uint64 `json:"timestamp"`
// SequencerAddress the StarkNet identity of the sequencer submitting this block
SequencerAddress *felt.Felt `json:"sequencer_address"`
// The price of l1 gas in the block
L1GasPrice ResourcePrice `json:"l1_gas_price"`
// The price of l2 gas in the block
L2GasPrice ResourcePrice `json:"l2_gas_price"`
// The price of l1 data gas in the block
L1DataGasPrice ResourcePrice `json:"l1_data_gas_price"`
// Specifies whether the data of this block is published via blob data or calldata
L1DAMode L1DAMode `json:"l1_da_mode"`
// Semver of the current Starknet protocol
StarknetVersion string `json:"starknet_version"`
}
type BlockID ¶
type BlockID struct {
Number *uint64 `json:"block_number,omitempty"`
Hash *felt.Felt `json:"block_hash,omitempty"`
Tag string `json:"block_tag,omitempty"`
}
BlockID is a struct that is used to choose between different search types.
func WithBlockHash ¶
WithBlockHash returns a BlockID with the given hash.
Parameters: - h: The hash to use for the BlockID. Returns: - BlockID: A BlockID struct with the specified hash
func WithBlockNumber ¶
WithBlockNumber returns a BlockID with the given block number.
Parameters:
- n: The block number to use for the BlockID.
Returns:
- BlockID: A BlockID struct with the specified block number
func WithBlockTag ¶
WithBlockTag creates a new BlockID with the specified tag.
Parameters: - tag: The tag for the BlockID Returns: - BlockID: A BlockID struct with the specified tag
func (BlockID) MarshalJSON ¶
MarshalJSON marshals the BlockID to JSON format.
It returns a byte slice and an error. The byte slice contains the JSON representation of the BlockID, while the error indicates any error that occurred during the marshaling process.
Parameters:
none
Returns: - []byte: the JSON representation of the BlockID - error: any error that occurred during the marshaling process
type BlockInvokeTxnV0 ¶ added in v0.4.4
type BlockInvokeTxnV0 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
InvokeTxnV0
}
func (BlockInvokeTxnV0) Hash ¶ added in v0.4.4
func (tx BlockInvokeTxnV0) Hash() *felt.Felt
Hash returns the transaction hash of the BlockInvokeTxnV0.
type BlockInvokeTxnV1 ¶ added in v0.4.4
type BlockInvokeTxnV1 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
InvokeTxnV1
}
func (BlockInvokeTxnV1) Hash ¶ added in v0.4.4
func (tx BlockInvokeTxnV1) Hash() *felt.Felt
Hash returns the hash of the BlockInvokeTxnV1 transaction.
type BlockInvokeTxnV3 ¶ added in v0.7.1
type BlockInvokeTxnV3 struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
InvokeTxnV3
}
func (BlockInvokeTxnV3) Hash ¶ added in v0.7.1
func (tx BlockInvokeTxnV3) Hash() *felt.Felt
Hash returns the hash of the BlockInvokeTxnV3 transaction.
type BlockL1HandlerTxn ¶ added in v0.4.4
type BlockL1HandlerTxn struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
L1HandlerTxn
}
func (BlockL1HandlerTxn) Hash ¶ added in v0.4.4
func (tx BlockL1HandlerTxn) Hash() *felt.Felt
Hash returns the hash of the BlockL1HandlerTxn.
type BlockStatus ¶
type BlockStatus string
const ( BlockStatus_Pending BlockStatus = "PENDING" BlockStatus_AcceptedOnL2 BlockStatus = "ACCEPTED_ON_L2" BlockStatus_AcceptedOnL1 BlockStatus = "ACCEPTED_ON_L1" BlockStatus_Rejected BlockStatus = "REJECTED" )
func (BlockStatus) MarshalJSON ¶
func (bs BlockStatus) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of BlockStatus.
Parameters:
none
Returns: - []byte: a byte slice - error: an error if any
func (*BlockStatus) UnmarshalJSON ¶
func (bs *BlockStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON representation of a BlockStatus.
It takes in a byte slice containing the JSON data to be unmarshaled. The function returns an error if there is an issue unmarshaling the data.
Parameters: - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshaled Returns: - error: an error if the unmarshaling fails
type BlockTransaction ¶ added in v0.4.4
type BlockTransaction struct {
IBlockTransaction
}
func (*BlockTransaction) UnmarshalJSON ¶ added in v0.7.1
func (txn *BlockTransaction) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the data into a BlockTransaction object.
It takes a byte slice as the parameter, representing the JSON data to be unmarshalled. The function returns an error if the unmarshalling process fails.
Parameters: - data: The JSON data to be unmarshalled Returns: - error: An error if the unmarshalling process fails
type BlockTransactions ¶ added in v0.4.4
type BlockTransactions []IBlockTransaction
func (*BlockTransactions) UnmarshalJSON ¶ added in v0.4.4
func (txns *BlockTransactions) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the data into a BlockTransactions object.
It takes a byte slice as the parameter, representing the JSON data to be unmarshalled. The function returns an error if the unmarshalling process fails.
Parameters: - data: The JSON data to be unmarshalled Returns: - error: An error if the unmarshalling process fails
type BlockTxHashes ¶ added in v0.4.4
type BlockTxHashes struct {
BlockHeader
Status BlockStatus `json:"status"`
// Transactions The hashes of the transactions included in this block
Transactions []*felt.Felt `json:"transactions"`
}
type BlockWithReceipts ¶ added in v0.7.0
type BlockWithReceipts struct {
BlockHeader
Status BlockStatus `json:"status"`
BlockBodyWithReceipts
}
encoding/json doesn't support inlining fields
type BroadcastDeclareTxnV3 ¶ added in v0.6.0
type BroadcastDeclareTxnV3 struct {
Type TransactionType `json:"type"`
SenderAddress *felt.Felt `json:"sender_address"`
CompiledClassHash *felt.Felt `json:"compiled_class_hash"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
ContractClass *contracts.ContractClass `json:"contract_class"`
ResourceBounds ResourceBoundsMapping `json:"resource_bounds"`
Tip U64 `json:"tip"`
// The data needed to allow the paymaster to pay for the transaction in native tokens
PayMasterData []*felt.Felt `json:"paymaster_data"`
// The data needed to deploy the account contract from which this tx will be initiated
AccountDeploymentData []*felt.Felt `json:"account_deployment_data"`
// The storage domain of the account's nonce (an account has a nonce per DA mode)
NonceDataMode DataAvailabilityMode `json:"nonce_data_availability_mode"`
// The storage domain of the account's balance from which fee will be charged
FeeMode DataAvailabilityMode `json:"fee_data_availability_mode"`
}
type BroadcastDeployAccountTxnV3 ¶ added in v0.6.0
type BroadcastDeployAccountTxnV3 struct {
DeployAccountTxnV3
}
type BroadcastInvokeTxnV3 ¶ added in v0.8.0
type BroadcastInvokeTxnV3 struct {
InvokeTxnV3
}
type BroadcastTxn ¶ added in v0.5.0
type BroadcastTxn interface{}
type ClassOutput ¶ added in v0.4.3
type ClassOutput interface{}
type CompilationErrData ¶ added in v0.8.0
type CompilationErrData struct {
CompilationError string `json:"compilation_error,omitempty"`
}
Structured type for the ErrCompilationError data
func (*CompilationErrData) ErrorMessage ¶ added in v0.8.0
func (c *CompilationErrData) ErrorMessage() string
type ContractErrData ¶ added in v0.8.0
type ContractErrData struct {
RevertError ContractExecutionError `json:"revert_error,omitempty"`
}
Structured type for the ErrContractError data
func (*ContractErrData) ErrorMessage ¶ added in v0.8.0
func (c *ContractErrData) ErrorMessage() string
type ContractExecutionError ¶ added in v0.8.0
type ContractExecutionError struct {
// the error raised during execution
Message string `json:",omitempty"`
ContractExecErrInner *ContractExecutionErrorInner `json:",omitempty"`
}
structured error that can later be processed by wallets or sdks
func (*ContractExecutionError) MarshalJSON ¶ added in v0.8.0
func (contractEx *ContractExecutionError) MarshalJSON() ([]byte, error)
func (*ContractExecutionError) UnmarshalJSON ¶ added in v0.8.0
func (contractEx *ContractExecutionError) UnmarshalJSON(data []byte) error
type ContractExecutionErrorInner ¶ added in v0.8.0
type ContractExecutionErrorInner struct {
ContractAddress *felt.Felt `json:"contract_address"`
ClassHash *felt.Felt `json:"class_hash"`
Selector *felt.Felt `json:"selector"`
Error *ContractExecutionError `json:"error"`
}
can be either this struct or a string. The parent type will handle the unmarshalling
type ContractLeavesData ¶ added in v0.8.0
type ContractLeavesData struct {
Nonce *felt.Felt `json:"nonce"`
ClassHash *felt.Felt `json:"class_hash"`
StorageRoot *felt.Felt `json:"storage_root,omitempty"`
}
The nonce and class hash for each requested contract address, in the order in which they appear in the request. These values are needed to construct the associated leaf node
type ContractNonce ¶
type ContractNonce struct {
// ContractAddress is the address of the contract
ContractAddress *felt.Felt `json:"contract_address"`
// Nonce is the nonce for the given address at the end of the block"
Nonce *felt.Felt `json:"nonce"`
}
ContractNonce is a the updated nonce per contract address
type ContractStorageDiffItem ¶
type ContractStorageDiffItem struct {
// ContractAddress is the contract address for which the state changed
Address *felt.Felt `json:"address"`
StorageEntries []StorageEntry `json:"storage_entries"`
}
ContractStorageDiffItem is a change in a single storage item
type ContractStorageKeys ¶ added in v0.8.0
type ContractsProof ¶ added in v0.8.0
type ContractsProof struct {
// The nodes in the union of the paths from the contracts tree root to the requested leaves
Nodes []NodeHashToNode `json:"nodes"`
ContractLeavesData []ContractLeavesData `json:"contract_leaves_data"`
}
type DataAvailabilityMode ¶ added in v0.6.0
type DataAvailabilityMode string
DA_MODE: Specifies a storage domain in Starknet. Each domain has different guarantees regarding availability
const ( DAModeL1 DataAvailabilityMode = "L1" DAModeL2 DataAvailabilityMode = "L2" )
func (DataAvailabilityMode) MarshalJSON ¶ added in v0.8.0
func (da DataAvailabilityMode) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. It validates that the DataAvailabilityMode is either L1 or L2 before marshaling.
func (*DataAvailabilityMode) UInt64 ¶ added in v0.6.0
func (da *DataAvailabilityMode) UInt64() (uint64, error)
type DeclareTxnTrace ¶ added in v0.4.3
type DeclareTxnTrace struct {
ValidateInvocation *FnInvocation `json:"validate_invocation,omitempty"`
FeeTransferInvocation *FnInvocation `json:"fee_transfer_invocation,omitempty"`
StateDiff *StateDiff `json:"state_diff,omitempty"`
Type TransactionType `json:"type"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
the execution trace of a declare transaction
type DeclareTxnType ¶ added in v0.4.6
type DeclareTxnType interface{}
type DeclareTxnV0 ¶ added in v0.4.4
type DeclareTxnV0 struct {
Type TransactionType `json:"type"`
// SenderAddress the address of the account contract sending the declaration transaction
SenderAddress *felt.Felt `json:"sender_address"`
MaxFee *felt.Felt `json:"max_fee"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
ClassHash *felt.Felt `json:"class_hash"`
}
func (DeclareTxnV0) GetType ¶ added in v0.4.4
func (tx DeclareTxnV0) GetType() TransactionType
type DeclareTxnV1 ¶ added in v0.4.3
type DeclareTxnV1 struct {
Type TransactionType `json:"type"`
// SenderAddress the address of the account contract sending the declaration transaction
SenderAddress *felt.Felt `json:"sender_address"`
MaxFee *felt.Felt `json:"max_fee"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
// ClassHash the hash of the declared class
ClassHash *felt.Felt `json:"class_hash"`
}
func (DeclareTxnV1) GetType ¶ added in v0.4.4
func (tx DeclareTxnV1) GetType() TransactionType
type DeclareTxnV2 ¶ added in v0.4.3
type DeclareTxnV2 struct {
Type TransactionType `json:"type"`
// SenderAddress the address of the account contract sending the declaration transaction
SenderAddress *felt.Felt `json:"sender_address"`
CompiledClassHash *felt.Felt `json:"compiled_class_hash"`
MaxFee *felt.Felt `json:"max_fee"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
ClassHash *felt.Felt `json:"class_hash"`
}
func (DeclareTxnV2) GetType ¶ added in v0.4.4
func (tx DeclareTxnV2) GetType() TransactionType
type DeclareTxnV3 ¶ added in v0.6.0
type DeclareTxnV3 struct {
Type TransactionType `json:"type"`
SenderAddress *felt.Felt `json:"sender_address"`
CompiledClassHash *felt.Felt `json:"compiled_class_hash"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
ClassHash *felt.Felt `json:"class_hash"`
ResourceBounds ResourceBoundsMapping `json:"resource_bounds"`
Tip U64 `json:"tip"`
// The data needed to allow the paymaster to pay for the transaction in native tokens
PayMasterData []*felt.Felt `json:"paymaster_data"`
// The data needed to deploy the account contract from which this tx will be initiated
AccountDeploymentData []*felt.Felt `json:"account_deployment_data"`
// The storage domain of the account's nonce (an account has a nonce per DA mode)
NonceDataMode DataAvailabilityMode `json:"nonce_data_availability_mode"`
// The storage domain of the account's balance from which fee will be charged
FeeMode DataAvailabilityMode `json:"fee_data_availability_mode"`
}
func (DeclareTxnV3) GetType ¶ added in v0.6.0
func (tx DeclareTxnV3) GetType() TransactionType
type DeclaredClassesItem ¶ added in v0.4.3
type DeclaredClassesItem struct {
//The hash of the declared class
ClassHash *felt.Felt `json:"class_hash"`
//The Cairo assembly hash corresponding to the declared class
CompiledClassHash *felt.Felt `json:"compiled_class_hash"`
}
DeclaredClassesItem is an object with class_hash and compiled_class_hash
type DeployAccountTxn ¶
type DeployAccountTxn struct {
MaxFee *felt.Felt `json:"max_fee"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
Type TransactionType `json:"type"`
// ClassHash The hash of the deployed contract's class
ClassHash *felt.Felt `json:"class_hash"`
// ContractAddressSalt The salt for the address of the deployed contract
ContractAddressSalt *felt.Felt `json:"contract_address_salt"`
// ConstructorCalldata The parameters passed to the constructor
ConstructorCalldata []*felt.Felt `json:"constructor_calldata"`
}
DeployAccountTxn The structure of a deployAccount transaction.
func (DeployAccountTxn) GetType ¶ added in v0.4.4
func (tx DeployAccountTxn) GetType() TransactionType
type DeployAccountTxnTrace ¶ added in v0.4.3
type DeployAccountTxnTrace struct {
ValidateInvocation *FnInvocation `json:"validate_invocation,omitempty"`
//the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)
ConstructorInvocation FnInvocation `json:"constructor_invocation"`
FeeTransferInvocation *FnInvocation `json:"fee_transfer_invocation,omitempty"`
StateDiff *StateDiff `json:"state_diff,omitempty"`
Type TransactionType `json:"type"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
the execution trace of a deploy account transaction
type DeployAccountTxnV3 ¶ added in v0.6.0
type DeployAccountTxnV3 struct {
Type TransactionType `json:"type"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
ContractAddressSalt *felt.Felt `json:"contract_address_salt"`
ConstructorCalldata []*felt.Felt `json:"constructor_calldata"`
ClassHash *felt.Felt `json:"class_hash"`
ResourceBounds ResourceBoundsMapping `json:"resource_bounds"`
Tip U64 `json:"tip"`
// The data needed to allow the paymaster to pay for the transaction in native tokens
PayMasterData []*felt.Felt `json:"paymaster_data"`
// The storage domain of the account's nonce (an account has a nonce per DA mode)
NonceDataMode DataAvailabilityMode `json:"nonce_data_availability_mode"`
// The storage domain of the account's balance from which fee will be charged
FeeMode DataAvailabilityMode `json:"fee_data_availability_mode"`
}
func (DeployAccountTxnV3) GetType ¶ added in v0.6.0
func (tx DeployAccountTxnV3) GetType() TransactionType
type DeployAccountType ¶ added in v0.4.6
type DeployAccountType interface{}
type DeployTxn ¶
type DeployTxn struct {
// ClassHash The hash of the deployed contract's class
ClassHash *felt.Felt `json:"class_hash"`
Version TransactionVersion `json:"version"`
Type TransactionType `json:"type"`
ContractAddressSalt *felt.Felt `json:"contract_address_salt"`
ConstructorCalldata []*felt.Felt `json:"constructor_calldata"`
}
DeployTxn The structure of a deploy transaction. Note that this transaction type is deprecated and will no longer be supported in future versions
func (DeployTxn) GetType ¶ added in v0.4.4
func (tx DeployTxn) GetType() TransactionType
type DeployedContractItem ¶
type DeployedContractItem struct {
// ContractAddress is the address of the contract
Address *felt.Felt `json:"address"`
// ClassHash is the hash of the contract code
ClassHash *felt.Felt `json:"class_hash"`
}
DeployedContractItem A new contract deployed as part of the new state
type EdgeNode ¶ added in v0.8.0
type EdgeNode struct {
// an integer whose binary representation represents the path from the current node to its highest non-zero descendant (bounded by 2^251)
Path NumAsHex `json:"path"`
// the length of the path (bounded by 251)
Length uint `json:"length"`
// the hash of the unique non-zero maximal-height descendant node
Child *felt.Felt `json:"child"`
}
Represents a path to the highest non-zero descendant node
type EmittedEvent ¶
type EmittedEvent struct {
Event
// BlockHash the hash of the block in which the event was emitted
BlockHash *felt.Felt `json:"block_hash,omitempty"`
// BlockNumber the number of the block in which the event was emitted
BlockNumber uint64 `json:"block_number,omitempty"`
// TransactionHash the transaction that emitted the event
TransactionHash *felt.Felt `json:"transaction_hash"`
}
EmittedEvent an event emitted as a result of transaction execution
type EntryPointType ¶ added in v0.4.3
type EntryPointType string
const ( External EntryPointType = "EXTERNAL" L1Handler EntryPointType = "L1_HANDLER" Constructor EntryPointType = "CONSTRUCTOR" )
type Event ¶
type Event struct {
FromAddress *felt.Felt `json:"from_address"`
EventContent
}
type EventChunk ¶ added in v0.4.3
type EventChunk struct {
Events []EmittedEvent `json:"events"`
ContinuationToken string `json:"continuation_token,omitempty"`
}
type EventContent ¶ added in v0.8.0
type EventFilter ¶
type EventFilter struct {
// FromBlock from block
FromBlock BlockID `json:"from_block"`
// ToBlock to block
ToBlock BlockID `json:"to_block,omitempty"`
// Address from contract
Address *felt.Felt `json:"address,omitempty"`
// Keys the values used to filter the events
Keys [][]*felt.Felt `json:"keys,omitempty"`
}
type EventSubscriptionInput ¶ added in v0.8.0
type EventSubscriptionInput struct {
FromAddress *felt.Felt `json:"from_address,omitempty"` // Optional. Filter events by from_address which emitted the event
Keys [][]*felt.Felt `json:"keys,omitempty"` // Optional. Per key (by position), designate the possible values to be matched for events to be returned. Empty array designates 'any' value
BlockID BlockID `json:"block_id,omitempty"` // Optional. The block to get notifications from, default is latest, limited to 1024 blocks back
}
type EventsInput ¶
type EventsInput struct {
EventFilter
ResultPageRequest
}
type ExecInvocation ¶ added in v0.5.0
type ExecInvocation struct {
*FnInvocation
RevertReason string `json:"revert_reason,omitempty"`
}
type ExecutionResources ¶ added in v0.5.0
type ExecutionResources struct {
// l1 gas consumed by this transaction, used for l2-->l1 messages and state updates if blobs are not used
L1Gas uint `json:"l1_gas"`
// data gas consumed by this transaction, 0 if blobs are not used
L1DataGas uint `json:"l1_data_gas"`
// l2 gas consumed by this transaction, used for computation and calldata
L2Gas uint `json:"l2_gas"`
}
type FeeEstimation ¶ added in v0.7.1
type FeeEstimation struct {
// The Ethereum gas consumption of the transaction, charged for L1->L2 messages and, depending on the block's DA_MODE, state diffs
L1GasConsumed *felt.Felt `json:"l1_gas_consumed"`
// The gas price (in wei or fri, depending on the tx version) that was used in the cost estimation.
L1GasPrice *felt.Felt `json:"l1_gas_price"`
// The L2 gas consumption of the transaction
L2GasConsumed *felt.Felt `json:"l2_gas_consumed"`
// The L2 gas price (in wei or fri, depending on the tx version) that was used in the cost estimation.
L2GasPrice *felt.Felt `json:"l2_gas_price"`
// The Ethereum data gas consumption of the transaction.
L1DataGasConsumed *felt.Felt `json:"l1_data_gas_consumed"`
// The data gas price (in wei or fri, depending on the tx version) that was used in the cost estimation.
L1DataGasPrice *felt.Felt `json:"l1_data_gas_price"`
// The estimated fee for the transaction (in wei or fri, depending on the tx version), equals to gas_consumed*gas_price + data_gas_consumed*data_gas_price.
OverallFee *felt.Felt `json:"overall_fee"`
// Units in which the fee is given
FeeUnit FeePaymentUnit `json:"unit"`
}
a sequence of fee estimation where the i'th estimate corresponds to the i'th transaction
type FeePayment ¶ added in v0.6.0
type FeePayment struct {
Amount *felt.Felt `json:"amount"`
Unit FeePaymentUnit `json:"unit"`
}
type FeePaymentUnit ¶ added in v0.6.0
type FeePaymentUnit string
const ( UnitWei FeePaymentUnit = "WEI" UnitStrk FeePaymentUnit = "FRI" )
type FnInvocation ¶ added in v0.4.3
type FnInvocation struct {
FunctionCall
//The address of the invoking contract. 0 for the root invocation
CallerAddress *felt.Felt `json:"caller_address"`
// The hash of the class being called
ClassHash *felt.Felt `json:"class_hash"`
EntryPointType EntryPointType `json:"entry_point_type"`
CallType CallType `json:"call_type"`
//The value returned from the function invocation
Result []*felt.Felt `json:"result"`
// The calls made by this invocation
NestedCalls []FnInvocation `json:"calls"`
// The events emitted in this invocation
InvocationEvents []OrderedEvent `json:"events"`
// The messages sent by this invocation to L1
L1Messages []OrderedMsg `json:"messages"`
// Resources consumed by the internal call
ExecutionResources InnerCallExecutionResources `json:"execution_resources"`
// True if this inner call panicked
IsReverted bool `json:"is_reverted"`
}
type FunctionCall ¶
type FunctionCall struct {
ContractAddress *felt.Felt `json:"contract_address"`
EntryPointSelector *felt.Felt `json:"entry_point_selector"`
// Calldata The parameters passed to the function
Calldata []*felt.Felt `json:"calldata"`
}
FunctionCall function call information
type GlobalRoots ¶ added in v0.8.0
type IBlockTransaction ¶ added in v0.7.1
type InnerCallExecutionResources ¶ added in v0.8.0
type InnerCallExecutionResources struct {
// l1 gas consumed by this transaction, used for l2-->l1 messages and state updates if blobs are not used
L1Gas uint `json:"l1_gas"`
// l2 gas consumed by this transaction, used for computation and calldata
L2Gas uint `json:"l2_gas"`
}
the resources consumed by an inner call (does not account for state diffs since data is squashed across the transaction)
type InvokeFunctionCall ¶ added in v0.8.0
type InvokeFunctionCall struct {
// The address of the contract to invoke
ContractAddress *felt.Felt
// The name of the function to invoke
FunctionName string
// The parameters passed to the function
CallData []*felt.Felt
}
InvokeFunctionCall represents a function call to be invoked on a contract. It's a helper type used to build a FunctionCall for a v3 Invoke transaction.
type InvokeTxnTrace ¶ added in v0.4.3
type InvokeTxnTrace struct {
ValidateInvocation *FnInvocation `json:"validate_invocation,omitempty"`
//the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)
ExecuteInvocation ExecInvocation `json:"execute_invocation"`
FeeTransferInvocation *FnInvocation `json:"fee_transfer_invocation,omitempty"`
StateDiff *StateDiff `json:"state_diff,omitempty"`
Type TransactionType `json:"type"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
the execution trace of an invoke transaction
type InvokeTxnType ¶ added in v0.4.6
type InvokeTxnType interface{}
type InvokeTxnV0 ¶
type InvokeTxnV0 struct {
Type TransactionType `json:"type"`
MaxFee *felt.Felt `json:"max_fee"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
FunctionCall
}
func (InvokeTxnV0) GetType ¶ added in v0.4.4
func (tx InvokeTxnV0) GetType() TransactionType
type InvokeTxnV1 ¶
type InvokeTxnV1 struct {
MaxFee *felt.Felt `json:"max_fee"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
Type TransactionType `json:"type"`
SenderAddress *felt.Felt `json:"sender_address"`
// The data expected by the account's `execute` function (in most usecases, this includes the called contract address and a function selector)
Calldata []*felt.Felt `json:"calldata"`
}
func (InvokeTxnV1) GetType ¶ added in v0.4.4
func (tx InvokeTxnV1) GetType() TransactionType
type InvokeTxnV3 ¶ added in v0.6.0
type InvokeTxnV3 struct {
Type TransactionType `json:"type"`
SenderAddress *felt.Felt `json:"sender_address"`
Calldata []*felt.Felt `json:"calldata"`
Version TransactionVersion `json:"version"`
Signature []*felt.Felt `json:"signature"`
Nonce *felt.Felt `json:"nonce"`
ResourceBounds ResourceBoundsMapping `json:"resource_bounds"`
Tip U64 `json:"tip"`
// The data needed to allow the paymaster to pay for the transaction in native tokens
PayMasterData []*felt.Felt `json:"paymaster_data"`
// The data needed to deploy the account contract from which this tx will be initiated
AccountDeploymentData []*felt.Felt `json:"account_deployment_data"`
// The storage domain of the account's nonce (an account has a nonce per DA mode)
NonceDataMode DataAvailabilityMode `json:"nonce_data_availability_mode"`
// The storage domain of the account's balance from which fee will be charged
FeeMode DataAvailabilityMode `json:"fee_data_availability_mode"`
}
func (InvokeTxnV3) GetType ¶ added in v0.6.0
func (tx InvokeTxnV3) GetType() TransactionType
type L1DAMode ¶ added in v0.7.0
type L1DAMode int
func (L1DAMode) MarshalJSON ¶ added in v0.7.0
func (*L1DAMode) UnmarshalJSON ¶ added in v0.7.0
type L1HandlerTxn ¶
type L1HandlerTxn struct {
Type TransactionType `json:"type,omitempty"`
// Version of the transaction scheme
Version L1HandlerTxnVersion `json:"version"`
// Nonce
Nonce string `json:"nonce,omitempty"`
FunctionCall
}
func (L1HandlerTxn) GetType ¶ added in v0.4.4
func (tx L1HandlerTxn) GetType() TransactionType
type L1HandlerTxnTrace ¶ added in v0.4.3
type L1HandlerTxnTrace struct {
//the trace of the __execute__ call or constructor call, depending on the transaction type (none for declare transactions)
FunctionInvocation FnInvocation `json:"function_invocation"`
StateDiff *StateDiff `json:"state_diff,omitempty"`
ExecutionResources ExecutionResources `json:"execution_resources"`
Type TransactionType `json:"type"`
}
the execution trace of an L1 handler transaction
type L1HandlerTxnVersion ¶ added in v0.7.0
type L1HandlerTxnVersion string
const (
L1HandlerTxnVersionV0 L1HandlerTxnVersion = "0x0"
)
type MerkleNode ¶ added in v0.8.0
A node in the Merkle-Patricia tree, can be a leaf, binary node, or an edge node (EdgeNode or BinaryNode types)
func (*MerkleNode) MarshalJSON ¶ added in v0.8.0
func (m *MerkleNode) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for MerkleNode It marshals the data into an EdgeNode or BinaryNode depending on the type
func (*MerkleNode) UnmarshalJSON ¶ added in v0.8.0
func (m *MerkleNode) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for MerkleNode It unmarshals the data into an EdgeNode or BinaryNode depending on the type
type MessageStatusResp ¶ added in v0.8.0
type MessageStatusResp struct {
// The hash of a L1 handler transaction
TransactionHash *felt.Felt `json:"transaction_hash"`
// The finality status of the transaction, including the case the txn is still in the mempool or failed validation during the block construction phase
FinalityStatus TxnStatus `json:"finality_status"`
// The failure reason, only appears if finality_status is REJECTED
FailureReason string `json:"failure_reason,omitempty"`
}
type MsgFromL1 ¶ added in v0.4.4
type MsgFromL1 struct {
// FromAddress The address of the L1 contract sending the message
FromAddress string `json:"from_address"`
// ToAddress The target L2 address the message is sent to
ToAddress *felt.Felt `json:"to_address"`
// EntryPointSelector The selector of the l1_handler in invoke in the target contract
Selector *felt.Felt `json:"entry_point_selector"`
//Payload The payload of the message
Payload []*felt.Felt `json:"payload"`
}
type MsgToL1 ¶
type MsgToL1 struct {
// FromAddress The address of the L2 contract sending the message
FromAddress *felt.Felt `json:"from_address"`
// ToAddress The target L1 address the message is sent to
ToAddress *felt.Felt `json:"to_address"`
//Payload The payload of the message
Payload []*felt.Felt `json:"payload"`
}
type NewTxnStatusResp ¶ added in v0.8.0
type NewTxnStatusResp struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
Status TxnStatusResp `json:"status"`
}
type NodeHashToNode ¶ added in v0.8.0
type NodeHashToNode struct {
NodeHash *felt.Felt `json:"node_hash"`
Node MerkleNode `json:"node"`
}
A node_hash -> node mapping of all the nodes in the union of the paths between the requested leaves and the root
type OrderedEvent ¶ added in v0.5.0
type OrderedEvent struct {
// The order of the event within the transaction
Order int `json:"order"`
*EventContent
}
type OrderedMsg ¶ added in v0.5.0
type PendingBlock ¶
type PendingBlock struct {
PendingBlockHeader
BlockTransactions
}
type PendingBlockHeader ¶ added in v0.5.0
type PendingBlockHeader struct {
// ParentHash The hash of this block's parent
ParentHash *felt.Felt `json:"parent_hash"`
// Timestamp the time in which the block was created, encoded in Unix time
Timestamp uint64 `json:"timestamp"`
// SequencerAddress the StarkNet identity of the sequencer submitting this block
SequencerAddress *felt.Felt `json:"sequencer_address"`
// The price of l1 gas in the block
L1GasPrice ResourcePrice `json:"l1_gas_price"`
// The price of l2 gas in the block
L2GasPrice ResourcePrice `json:"l2_gas_price"`
// Semver of the current Starknet protocol
StarknetVersion string `json:"starknet_version"`
// The price of l1 data gas in the block
L1DataGasPrice ResourcePrice `json:"l1_data_gas_price"`
// Specifies whether the data of this block is published via blob data or calldata
L1DAMode L1DAMode `json:"l1_da_mode"`
}
type PendingBlockTxHashes ¶ added in v0.4.4
type PendingBlockTxHashes struct {
PendingBlockHeader
Transactions []*felt.Felt `json:"transactions"`
}
type PendingBlockWithReceipts ¶ added in v0.7.0
type PendingBlockWithReceipts struct {
PendingBlockHeader
BlockBodyWithReceipts
}
The dynamic block being constructed by the sequencer. Note that this object will be deprecated upon decentralization.
type PendingStateUpdate ¶ added in v0.4.3
type PendingStateUpdate struct {
// OldRoot is the previous global state root.
OldRoot *felt.Felt `json:"old_root"`
// AcceptedTime is when the block was accepted on L1.
StateDiff StateDiff `json:"state_diff"`
}
PENDING_STATE_UPDATE in spec
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider provides the provider for starknet.go/rpc implementation.
func NewProvider ¶
func NewProvider(url string, options ...client.ClientOption) (*Provider, error)
NewProvider creates a new HTTP rpc Provider instance.
func (*Provider) AddDeclareTransaction ¶
func (provider *Provider) AddDeclareTransaction(ctx context.Context, declareTransaction *BroadcastDeclareTxnV3) (*AddDeclareTransactionResponse, error)
AddDeclareTransaction submits a declare transaction to the StarkNet contract.
Parameters: - ctx: The context.Context object for the request. - declareTransaction: The input for the declare transaction. Returns: - *AddDeclareTransactionResponse: The response of submitting the declare transaction - error: an error if any
func (*Provider) AddDeployAccountTransaction ¶
func (provider *Provider) AddDeployAccountTransaction(ctx context.Context, deployAccountTransaction *BroadcastDeployAccountTxnV3) (*AddDeployAccountTransactionResponse, error)
AddDeployAccountTransaction adds a DEPLOY_ACCOUNT transaction to the provider.
Parameters: - ctx: The context of the function - deployAccountTransaction: The deploy account transaction to be added Returns: - *AddDeployAccountTransactionResponse: the response of adding the deploy account transaction or an error
func (*Provider) AddInvokeTransaction ¶
func (provider *Provider) AddInvokeTransaction(ctx context.Context, invokeTxn *BroadcastInvokeTxnV3) (*AddInvokeTransactionResponse, error)
AddInvokeTransaction adds an invoke transaction to the provider.
Parameters: - ctx: The context for the function. - invokeTxn: The invoke transaction to be added. Returns: - *AddInvokeTransactionResponse: the response of adding the invoke transaction - error: an error if any
func (*Provider) BlockHashAndNumber ¶
func (provider *Provider) BlockHashAndNumber(ctx context.Context) (*BlockHashAndNumberOutput, error)
BlockHashAndNumber retrieves the hash and number of the current block.
Parameters: - ctx: The context to use for the request. Returns: - *BlockHashAndNumberOutput: The hash and number of the current block - error: An error if any
func (*Provider) BlockNumber ¶
BlockNumber returns the block number of the current block.
Parameters: - ctx: The context to use for the request Returns: - uint64: The block number - error: An error if any
func (*Provider) BlockTransactionCount ¶
func (provider *Provider) BlockTransactionCount(ctx context.Context, blockID BlockID) (uint64, error)
BlockTransactionCount returns the number of transactions in a specific block.
Parameters: - ctx: The context.Context object to handle cancellation signals and timeouts - blockID: The ID of the block to retrieve the number of transactions from Returns: - uint64: The number of transactions in the block - error: An error, if any
func (*Provider) BlockWithReceipts ¶ added in v0.7.0
func (provider *Provider) BlockWithReceipts(ctx context.Context, blockID BlockID) (interface{}, error)
Get block information with full transactions and receipts given the block id
func (*Provider) BlockWithTxHashes ¶
func (provider *Provider) BlockWithTxHashes(ctx context.Context, blockID BlockID) (interface{}, error)
BlockWithTxHashes retrieves the block with transaction hashes for the given block ID.
Parameters: - ctx: The context.Context object for controlling the function call - blockID: The ID of the block to retrieve the transactions from Returns: - interface{}: The retrieved block - error: An error, if any
func (*Provider) BlockWithTxs ¶
BlockWithTxs retrieves a block with its transactions given the block id.
Parameters: - ctx: The context.Context object for the request - blockID: The ID of the block to retrieve Returns: - interface{}: The retrieved block - error: An error, if any
func (*Provider) Call ¶
func (provider *Provider) Call(ctx context.Context, request FunctionCall, blockID BlockID) ([]*felt.Felt, error)
Call calls the Starknet Provider's function with the given (Starknet) request and block ID.
Parameters:
- ctx: the context.Context object for the function call
- request: the FunctionCall object representing the request
- blockID: the BlockID object representing the block ID
Returns
- []*felt.Felt: the result of the function call
- error: an error if any occurred during the execution
func (*Provider) ChainID ¶
ChainID returns the chain ID for transaction replay protection.
Parameters: - ctx: The context.Context object for the function Returns: - string: The chain ID - error: An error if any occurred during the execution
func (*Provider) Class ¶
func (provider *Provider) Class(ctx context.Context, blockID BlockID, classHash *felt.Felt) (ClassOutput, error)
Class retrieves the class information from the Provider with the given hash.
Parameters: - ctx: The context.Context object - blockID: The BlockID object - classHash: The *felt.Felt object Returns: - ClassOutput: The output of the class. - error: An error if any occurred during the execution.
func (*Provider) ClassAt ¶
func (provider *Provider) ClassAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (ClassOutput, error)
ClassAt returns the class at the specified blockID and contractAddress.
Parameters: - ctx: The context.Context object for the function - blockID: The BlockID of the class - contractAddress: The address of the contract Returns: - ClassOutput: The output of the class - error: An error if any occurred during the execution
func (*Provider) ClassHashAt ¶
func (provider *Provider) ClassHashAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
ClassHashAt retrieves the class hash at the given block ID and contract address.
Parameters: - ctx: The context.Context used for the request - blockID: The ID of the block - contractAddress: The address of the contract Returns: - *felt.Felt: The class hash - error: An error if any occurred during the execution
func (*Provider) CompiledCasm ¶ added in v0.8.0
func (provider *Provider) CompiledCasm(ctx context.Context, classHash *felt.Felt) (*contracts.CasmClass, error)
Get the CASM code resulting from compiling a given class
Parameters:
- ctx: The context.Context used for the request
- classHash: The hash of the contract class whose CASM will be returned
Returns:
- CasmCompiledContractClass: The compiled contract class
- error: An error if any occurred during the execution
func (*Provider) EstimateFee ¶
func (provider *Provider) EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, blockID BlockID) ([]FeeEstimation, error)
Estimates the resources required by a given sequence of transactions when applied on a given state. If one of the transactions reverts or fails due to any reason (e.g. validation failure or an internal error), a TRANSACTION_EXECUTION_ERROR is returned. The estimate is given in fri.
Parameters: - ctx: The context of the function call - requests: A sequence of transactions to estimate, running each transaction on the state resulting from applying all the previous ones - simulationFlags: Describes what parts of the transaction should be executed - blockID: The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on Returns: - []FeeEstimation: A sequence of fee estimation where the i'th estimate corresponds to the i'th transaction - error: An error if any occurred during the execution
func (*Provider) EstimateMessageFee ¶ added in v0.4.4
func (provider *Provider) EstimateMessageFee(ctx context.Context, msg MsgFromL1, blockID BlockID) (*FeeEstimation, error)
EstimateMessageFee estimates the L2 fee of a message sent on L1 (Provider struct).
Parameters: - ctx: The context of the function call - msg: The message to estimate the fee for - blockID: The ID of the block to estimate the fee in Returns: - *FeeEstimation: the fee estimated for the message - error: an error if any occurred during the execution
func (*Provider) Events ¶
func (provider *Provider) Events(ctx context.Context, input EventsInput) (*EventChunk, error)
Events retrieves events from the provider matching the given filter.
Parameters: - ctx: The context to use for the request - input: The input parameters for retrieving events Returns - eventChunk: The retrieved events - error: An error if any
func (*Provider) GetMessagesStatus ¶ added in v0.8.0
func (provider *Provider) GetMessagesStatus(ctx context.Context, transactionHash NumAsHex) ([]MessageStatusResp, error)
Given an L1 tx hash, returns the associated l1_handler tx hashes and statuses for all L1 -> L2 messages sent by the l1 transaction, ordered by the L1 tx sending order
Parameters: - ctx: the context.Context object for cancellation and timeouts. - transactionHash: The hash of the L1 transaction that sent L1->L2 messages Returns: - [] MessageStatusResp: An array containing the status of the messages sent by the L1 transaction - error, if one arose.
func (*Provider) GetStorageProof ¶ added in v0.8.0
func (provider *Provider) GetStorageProof(ctx context.Context, storageProofInput StorageProofInput) (*StorageProofResult, error)
Get merkle paths in one of the state tries: global state, classes, individual contract. A single request can query for any mix of the three types of storage proofs (classes, contracts, and storage)
Parameters: - ctx: The context of the function call - storageProofInput: an input containing optional and required fields for the request Returns: - *StorageProofResult: The requested storage proofs. Note that if a requested leaf has the default value, the path to it may end in an edge node whose path is not a prefix of the requested leaf, thus effectively proving non-membership - error: an error if any occurred during the execution
func (*Provider) GetTransactionStatus ¶ added in v0.5.0
func (provider *Provider) GetTransactionStatus(ctx context.Context, transactionHash *felt.Felt) (*TxnStatusResp, error)
GetTransactionStatus gets the transaction status (possibly reflecting that the tx is still in the mempool, or dropped from it) Parameters: - ctx: the context.Context object for cancellation and timeouts. - transactionHash: the transaction hash as a felt Returns: - *GetTxnStatusResp: The transaction status - error, if one arose.
func (*Provider) Nonce ¶
func (provider *Provider) Nonce(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
Nonce retrieves the nonce for a given block ID and contract address.
Parameters: - ctx: is the context.Context for the function call - blockID: is the ID of the block - contractAddress: is the address of the contract Returns: - *felt.Felt: the contract's nonce at the requested state - error: an error if any
func (*Provider) SimulateTransactions ¶ added in v0.4.3
func (provider *Provider) SimulateTransactions(ctx context.Context, blockID BlockID, txns []BroadcastTxn, simulationFlags []SimulationFlag) ([]SimulatedTransaction, error)
SimulateTransactions simulates transactions on the blockchain. Simulate a given sequence of transactions on the requested state, and generate the execution traces. Note that some of the transactions may revert, in which case no error is thrown, but revert details can be seen on the returned trace object. Note that some of the transactions may revert, this will be reflected by the revert_error property in the trace. Other types of failures (e.g. unexpected error or failure in the validation phase) will result in TRANSACTION_EXECUTION_ERROR.
Parameters: - ctx: The context of the function call - blockID: The hash of the requested block, or number (height) of the requested block, or a block tag, for the block referencing the state or call the transaction on. - txns: A sequence of transactions to simulate, running each transaction on the state resulting from applying all the previous ones - simulationFlags: Describes what parts of the transaction should be executed Returns: - []SimulatedTransaction: The execution trace and consumed resources of the required transactions - error: An error if any occurred during the execution
func (*Provider) SpecVersion ¶ added in v0.5.0
SpecVersion returns the version of the Starknet JSON-RPC specification being used Parameters: None Returns: String of the Starknet JSON-RPC specification
func (*Provider) StateUpdate ¶
func (provider *Provider) StateUpdate(ctx context.Context, blockID BlockID) (*StateUpdateOutput, error)
StateUpdate is a function that performs a state update operation (gets the information about the result of executing the requested block).
Parameters: - ctx: The context.Context object for controlling the function call - blockID: The ID of the block to retrieve the transactions from Returns: - *StateUpdateOutput: The retrieved state update - error: An error, if any
func (*Provider) StorageAt ¶
func (provider *Provider) StorageAt(ctx context.Context, contractAddress *felt.Felt, key string, blockID BlockID) (string, error)
StorageAt retrieves the storage value of a given contract at a specific key and block ID.
Parameters: - ctx: The context.Context for the function - contractAddress: The address of the contract - key: The key for which to retrieve the storage value - blockID: The ID of the block at which to retrieve the storage value Returns: - string: The value of the storage - error: An error if any occurred during the execution
func (*Provider) Syncing ¶
func (provider *Provider) Syncing(ctx context.Context) (*SyncStatus, error)
Syncing retrieves the synchronization status of the provider.
Parameters: - ctx: The context.Context object for the function Returns: - *SyncStatus: The synchronization status - error: An error if any occurred during the execution
func (*Provider) TraceBlockTransactions ¶
func (provider *Provider) TraceBlockTransactions(ctx context.Context, blockID BlockID) ([]Trace, error)
TraceBlockTransactions retrieves the traces of transactions in a given block.
Parameters: - ctx: the context.Context object for controlling the request - blockHash: the hash of the block to retrieve the traces from Returns: - []Trace: a slice of Trace objects representing the traces of transactions in the block - error: an error if there was a problem retrieving the traces.
func (*Provider) TraceTransaction ¶ added in v0.5.0
func (provider *Provider) TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error)
TraceTransaction returns the transaction trace for the given transaction hash.
Parameters:
- ctx: the context.Context object for the request
- transactionHash: the transaction hash to trace
Returns:
- TxnTrace: the transaction trace
- error: an error if the transaction trace cannot be retrieved
func (*Provider) TransactionByBlockIdAndIndex ¶
func (provider *Provider) TransactionByBlockIdAndIndex(ctx context.Context, blockID BlockID, index uint64) (*BlockTransaction, error)
TransactionByBlockIdAndIndex retrieves a transaction by its block ID and index.
Parameters: - ctx: The context.Context object for the request. - blockID: The ID of the block containing the transaction. - index: The index of the transaction within the block. Returns: - BlockTransaction: The retrieved Transaction object - error: An error, if any
func (*Provider) TransactionByHash ¶
func (provider *Provider) TransactionByHash(ctx context.Context, hash *felt.Felt) (*BlockTransaction, error)
TransactionByHash retrieves the details and status of a transaction by its hash.
Parameters: - ctx: The context.Context object for the request. - hash: The hash of the transaction. Returns: - BlockTransaction: The retrieved Transaction - error: An error if any
func (*Provider) TransactionReceipt ¶
func (provider *Provider) TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (*TransactionReceiptWithBlockInfo, error)
TransactionReceipt fetches the transaction receipt for a given transaction hash.
Parameters: - ctx: the context.Context object for the request - transactionHash: the hash of the transaction as a Felt Returns: - TransactionReceipt: the transaction receipt - error: an error if any
type RPCData ¶ added in v0.8.0
type RPCData interface {
ErrorMessage() string
}
RPCData is the interface that all error data types must implement
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data RPCData `json:"data,omitempty"`
}
func Err ¶ added in v0.4.4
Err returns an RPCError based on the given code and data.
Parameters: - code: an integer representing the error code. - data: any data associated with the error. Returns - *RPCError: a pointer to an RPCError object.
func (*RPCError) UnmarshalJSON ¶ added in v0.8.0
UnmarshalJSON implements the json.Unmarshaler interface for RPCError. It handles the deserialization of JSON into an RPCError struct, with special handling for the Data field.
type ReplacedClassesItem ¶ added in v0.4.3
type ReplacedClassesItem struct {
//The address of the contract whose class was replaced
ContractClass *felt.Felt `json:"contract_address"`
//The new class hash
ClassHash *felt.Felt `json:"class_hash"`
}
contracts whose class was replaced
type Resource ¶ added in v0.6.0
type Resource string
const ( ResourceL1Gas Resource = "L1_GAS" ResourceL2Gas Resource = "L2_GAS" ResourceL1DataGas Resource = "L1_DATA" )
Values used in the Resource Bounds hash calculation Ref: https://docs.starknet.io/architecture-and-concepts/network-architecture/transactions/#v3_hash_calculation
type ResourceBounds ¶ added in v0.6.0
type ResourceBoundsMapping ¶ added in v0.6.0
type ResourceBoundsMapping struct {
// The max amount and max price per unit of L1 gas used in this tx
L1Gas ResourceBounds `json:"l1_gas"`
// The max amount and max price per unit of L1 blob gas used in this tx
L1DataGas ResourceBounds `json:"l1_data_gas"`
// The max amount and max price per unit of L2 gas used in this tx
L2Gas ResourceBounds `json:"l2_gas"`
}
type ResourcePrice ¶ added in v0.5.0
type ResultPageRequest ¶
type RpcProvider ¶ added in v0.4.6
type RpcProvider interface {
AddInvokeTransaction(ctx context.Context, invokeTxn *BroadcastInvokeTxnV3) (*AddInvokeTransactionResponse, error)
AddDeclareTransaction(ctx context.Context, declareTransaction *BroadcastDeclareTxnV3) (*AddDeclareTransactionResponse, error)
AddDeployAccountTransaction(ctx context.Context, deployAccountTransaction *BroadcastDeployAccountTxnV3) (*AddDeployAccountTransactionResponse, error)
BlockHashAndNumber(ctx context.Context) (*BlockHashAndNumberOutput, error)
BlockNumber(ctx context.Context) (uint64, error)
BlockTransactionCount(ctx context.Context, blockID BlockID) (uint64, error)
BlockWithReceipts(ctx context.Context, blockID BlockID) (interface{}, error)
BlockWithTxHashes(ctx context.Context, blockID BlockID) (interface{}, error)
BlockWithTxs(ctx context.Context, blockID BlockID) (interface{}, error)
Call(ctx context.Context, call FunctionCall, block BlockID) ([]*felt.Felt, error)
ChainID(ctx context.Context) (string, error)
Class(ctx context.Context, blockID BlockID, classHash *felt.Felt) (ClassOutput, error)
ClassAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (ClassOutput, error)
ClassHashAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
CompiledCasm(ctx context.Context, classHash *felt.Felt) (*contracts.CasmClass, error)
EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, blockID BlockID) ([]FeeEstimation, error)
EstimateMessageFee(ctx context.Context, msg MsgFromL1, blockID BlockID) (*FeeEstimation, error)
Events(ctx context.Context, input EventsInput) (*EventChunk, error)
GetStorageProof(ctx context.Context, storageProofInput StorageProofInput) (*StorageProofResult, error)
GetTransactionStatus(ctx context.Context, transactionHash *felt.Felt) (*TxnStatusResp, error)
GetMessagesStatus(ctx context.Context, transactionHash NumAsHex) ([]MessageStatusResp, error)
Nonce(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, error)
SimulateTransactions(ctx context.Context, blockID BlockID, txns []BroadcastTxn, simulationFlags []SimulationFlag) ([]SimulatedTransaction, error)
StateUpdate(ctx context.Context, blockID BlockID) (*StateUpdateOutput, error)
StorageAt(ctx context.Context, contractAddress *felt.Felt, key string, blockID BlockID) (string, error)
SpecVersion(ctx context.Context) (string, error)
Syncing(ctx context.Context) (*SyncStatus, error)
TraceBlockTransactions(ctx context.Context, blockID BlockID) ([]Trace, error)
TransactionByBlockIdAndIndex(ctx context.Context, blockID BlockID, index uint64) (*BlockTransaction, error)
TransactionByHash(ctx context.Context, hash *felt.Felt) (*BlockTransaction, error)
TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (*TransactionReceiptWithBlockInfo, error)
TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, error)
}
type SimulateTransactionInput ¶ added in v0.4.3
type SimulateTransactionInput struct {
//a sequence of transactions to simulate, running each transaction on the state resulting from applying all the previous ones
Txns []BroadcastTxn `json:"transactions"`
BlockID BlockID `json:"block_id"`
SimulationFlags []SimulationFlag `json:"simulation_flags"`
}
type SimulatedTransaction ¶ added in v0.4.3
type SimulatedTransaction struct {
TxnTrace `json:"transaction_trace"`
FeeEstimation `json:"fee_estimation"`
}
func (*SimulatedTransaction) UnmarshalJSON ¶ added in v0.7.1
func (txn *SimulatedTransaction) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the data into a SimulatedTransaction object.
It takes a byte slice as the parameter, representing the JSON data to be unmarshalled. The function returns an error if the unmarshalling process fails.
Parameters: - data: The JSON data to be unmarshalled Returns: - error: An error if the unmarshalling process fails
type SimulationFlag ¶ added in v0.4.3
type SimulationFlag string
const ( SKIP_FEE_CHARGE SimulationFlag = "SKIP_FEE_CHARGE" SKIP_EXECUTE SimulationFlag = "SKIP_EXECUTE" // Flags that indicate how to simulate a given transaction. By default, the sequencer behavior is replicated locally SKIP_VALIDATE SimulationFlag = "SKIP_VALIDATE" )
type StateDiff ¶
type StateDiff struct {
// list storage changes
StorageDiffs []ContractStorageDiffItem `json:"storage_diffs"`
// a list of Deprecated declared classes
DeprecatedDeclaredClasses []*felt.Felt `json:"deprecated_declared_classes"`
// list of DeclaredClassesItems objects
DeclaredClasses []DeclaredClassesItem `json:"declared_classes"`
// list of new contract deployed as part of the state update
DeployedContracts []DeployedContractItem `json:"deployed_contracts"`
// list of contracts whose class was replaced
ReplacedClasses []ReplacedClassesItem `json:"replaced_classes"`
// Nonces provides the updated nonces per contract addresses
Nonces []ContractNonce `json:"nonces"`
}
StateDiff is the change in state applied in this block, given as a mapping of addresses to the new values and/or new contracts.
type StateUpdateOutput ¶
type StateUpdateOutput struct {
// BlockHash is the block identifier,
BlockHash *felt.Felt `json:"block_hash"`
// NewRoot is the new global state root.
NewRoot *felt.Felt `json:"new_root"`
// Pending
PendingStateUpdate
}
STATE_UPDATE in spec
type StorageEntry ¶
type StorageProofInput ¶ added in v0.8.0
type StorageProofInput struct {
// Required. The hash of the requested block, or number (height) of the requested block, or a block tag
BlockID BlockID `json:"block_id"`
// Optional. A list of the class hashes for which we want to prove membership in the classes trie
ClassHashes []*felt.Felt `json:"class_hashes,omitempty"`
// Optional. A list of contracts for which we want to prove membership in the global state trie
ContractAddresses []*felt.Felt `json:"contract_addresses,omitempty"`
// Optional. A list of (contract_address, storage_keys) pairs
ContractsStorageKeys []ContractStorageKeys `json:"contracts_storage_keys,omitempty"`
}
type StorageProofResult ¶ added in v0.8.0
type StorageProofResult struct {
ClassesProof []NodeHashToNode `json:"classes_proof"`
ContractsProof ContractsProof `json:"contracts_proof"`
ContractsStorageProofs [][]NodeHashToNode `json:"contracts_storage_proofs"`
GlobalRoots GlobalRoots `json:"global_roots"`
}
The requested storage proofs. Note that if a requested leaf has the default value, the path to it may end in an edge node whose path is not a prefix of the requested leaf, thus effecitvely proving non-membership
type StringErrData ¶ added in v0.8.0
type StringErrData string
StringErrData handles plain string data messages
func (StringErrData) ErrorMessage ¶ added in v0.8.0
func (s StringErrData) ErrorMessage() string
type SubPendingTxns ¶ added in v0.8.0
type SubPendingTxns struct {
// The hash of the pending transaction. Always present.
TransactionHash *felt.Felt
// The full transaction details. Only present if transactionDetails is true.
Transaction *BlockTransaction
}
SubPendingTxns is the response of the starknet_subscribePendingTransactions subscription.
func (*SubPendingTxns) UnmarshalJSON ¶ added in v0.8.0
func (s *SubPendingTxns) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON data into a SubPendingTxns object.
Parameters: - data: The JSON data to be unmarshalled Returns: - error: An error if the unmarshalling process fails
type SubPendingTxnsInput ¶ added in v0.8.0
type SubPendingTxnsInput struct {
// Optional: Get all transaction details, and not only the hash. If not provided, only hash is returned. Default is false
TransactionDetails bool `json:"transaction_details,omitempty"`
// Optional: Filter transactions to only receive notification from address list
SenderAddress []*felt.Felt `json:"sender_address,omitempty"`
}
SubPendingTxnsInput is the optional input of the starknet_subscribePendingTransactions subscription.
type SyncStatus ¶
type SyncStatus struct {
SyncStatus *bool
StartingBlockHash *felt.Felt `json:"starting_block_hash,omitempty"`
StartingBlockNum NumAsHex `json:"starting_block_num,omitempty"`
CurrentBlockHash *felt.Felt `json:"current_block_hash,omitempty"`
CurrentBlockNum NumAsHex `json:"current_block_num,omitempty"`
HighestBlockHash *felt.Felt `json:"highest_block_hash,omitempty"`
HighestBlockNum NumAsHex `json:"highest_block_num,omitempty"`
}
SyncStatus is An object describing the node synchronization status
func (SyncStatus) MarshalJSON ¶
func (s SyncStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshals the SyncStatus struct into JSON format.
It returns a byte slice and an error. The byte slice represents the JSON encoding of the SyncStatus struct, while the error indicates any error that occurred during the marshaling process.
Parameters:
none
Returns: - []byte: the JSON encoding of the SyncStatus struct - error: any error that occurred during the marshaling process
func (*SyncStatus) UnmarshalJSON ¶
func (s *SyncStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON data into the SyncStatus struct.
Parameters:
-data: It takes a byte slice as input representing the JSON data to be unmarshaled.
Returns: - error: an error if the unmarshaling fails
type TXN ¶
type TXN struct {
Hash *felt.Felt `json:"transaction_hash,omitempty"`
Type TransactionType `json:"type"`
Version *felt.Felt `json:"version,omitempty"`
Nonce *felt.Felt `json:"nonce,omitempty"`
MaxFee *felt.Felt `json:"max_fee,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"`
SenderAddress *felt.Felt `json:"sender_address,omitempty"`
Signature *[]*felt.Felt `json:"signature,omitempty"`
Calldata *[]*felt.Felt `json:"calldata,omitempty"`
EntryPointSelector *felt.Felt `json:"entry_point_selector,omitempty"`
CompiledClassHash *felt.Felt `json:"compiled_class_hash,omitempty"`
ResourceBounds ResourceBoundsMapping `json:"resource_bounds"`
Tip U64 `json:"tip"`
PayMasterData []*felt.Felt `json:"paymaster_data"`
AccountDeploymentData []*felt.Felt `json:"account_deployment_data"`
NonceDataMode DataAvailabilityMode `json:"nonce_data_availability_mode"`
FeeMode DataAvailabilityMode `json:"fee_data_availability_mode"`
}
type Trace ¶ added in v0.4.3
type Trace struct {
TraceRoot TxnTrace `json:"trace_root,omitempty"`
TxnHash *felt.Felt `json:"transaction_hash,omitempty"`
}
A single pair of transaction hash and corresponding trace
func (*Trace) UnmarshalJSON ¶ added in v0.7.1
UnmarshalJSON unmarshals the data into a Trace object.
It takes a byte slice as the parameter, representing the JSON data to be unmarshalled. The function returns an error if the unmarshalling process fails.
Parameters: - data: The JSON data to be unmarshalled Returns: - error: An error if the unmarshalling process fails
type TraceStatus ¶ added in v0.8.0
type TraceStatus string
const ( TraceStatusReceived TraceStatus = "RECEIVED" TraceStatusRejected TraceStatus = "REJECTED" )
func (*TraceStatus) UnmarshalJSON ¶ added in v0.8.0
func (s *TraceStatus) UnmarshalJSON(data []byte) error
type TraceStatusErrData ¶ added in v0.8.0
type TraceStatusErrData struct {
Status TraceStatus `json:"status,omitempty"`
}
Structured type for the ErrTraceStatusError data
func (*TraceStatusErrData) ErrorMessage ¶ added in v0.8.0
func (t *TraceStatusErrData) ErrorMessage() string
type Transaction ¶
type Transaction interface {
GetType() TransactionType
}
type TransactionExecErrData ¶ added in v0.8.0
type TransactionExecErrData struct {
TransactionIndex int `json:"transaction_index,omitempty"`
ExecutionError ContractExecutionError `json:"execution_error,omitempty"`
}
Structured type for the ErrTransactionExecError data
func (*TransactionExecErrData) ErrorMessage ¶ added in v0.8.0
func (t *TransactionExecErrData) ErrorMessage() string
type TransactionReceipt ¶
type TransactionReceipt struct {
TransactionHash *felt.Felt `json:"transaction_hash"`
ActualFee FeePayment `json:"actual_fee"`
ExecutionStatus TxnExecutionStatus `json:"execution_status"`
FinalityStatus TxnFinalityStatus `json:"finality_status"`
Type TransactionType `json:"type,omitempty"`
MessagesSent []MsgToL1 `json:"messages_sent"`
RevertReason string `json:"revert_reason,omitempty"`
Events []Event `json:"events"`
ExecutionResources ExecutionResources `json:"execution_resources"`
ContractAddress *felt.Felt `json:"contract_address,omitempty"`
MessageHash NumAsHex `json:"message_hash,omitempty"`
}
TransactionReceipt represents the common structure of a transaction receipt.
type TransactionReceiptWithBlockInfo ¶ added in v0.7.0
type TransactionReceiptWithBlockInfo struct {
TransactionReceipt
BlockHash *felt.Felt `json:"block_hash,omitempty"`
BlockNumber uint `json:"block_number,omitempty"`
}
func (*TransactionReceiptWithBlockInfo) MarshalJSON ¶ added in v0.7.1
func (t *TransactionReceiptWithBlockInfo) MarshalJSON() ([]byte, error)
func (*TransactionReceiptWithBlockInfo) UnmarshalJSON ¶ added in v0.7.1
func (tr *TransactionReceiptWithBlockInfo) UnmarshalJSON(data []byte) error
type TransactionResponse ¶ added in v0.7.3
type TransactionResponse struct {
// Present for all transaction types
TransactionHash *felt.Felt `json:"transaction_hash"`
// Present only for declare transactions
ClassHash *felt.Felt `json:"class_hash,omitempty"`
// Present only for deploy transactions
ContractAddress *felt.Felt `json:"contract_address,omitempty"`
}
TransactionResponse is a generic response for all transaction types sent to the network.
type TransactionType ¶
type TransactionType string
const ( TransactionType_Declare TransactionType = "DECLARE" TransactionType_DeployAccount TransactionType = "DEPLOY_ACCOUNT" TransactionType_Deploy TransactionType = "DEPLOY" TransactionType_Invoke TransactionType = "INVOKE" TransactionType_L1Handler TransactionType = "L1_HANDLER" )
func (TransactionType) MarshalJSON ¶
func (tt TransactionType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the TransactionType to JSON.
Returns: - []byte: a byte slice - error: an error if any
func (*TransactionType) UnmarshalJSON ¶
func (tt *TransactionType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON data into a TransactionType.
The function modifies the value of the TransactionType pointer tt based on the unmarshaled data. The supported JSON values and their corresponding TransactionType values are:
- "DECLARE" maps to TransactionType_Declare
- "DEPLOY_ACCOUNT" maps to TransactionType_DeployAccount
- "DEPLOY" maps to TransactionType_Deploy
- "INVOKE" maps to TransactionType_Invoke
- "L1_HANDLER" maps to TransactionType_L1Handler
If none of the supported values match the input data, the function returns an error.
nil if the unmarshaling is successful.
Parameters: - data: It takes a byte slice as input representing the JSON data to be unmarshaled Returns: - error: an error if the unmarshaling fails
type TransactionVersion ¶
type TransactionVersion string
string must be NUM_AS_HEX
const ( TransactionV0 TransactionVersion = "0x0" TransactionV0WithQueryBit TransactionVersion = "0x100000000000000000000000000000000" TransactionV1 TransactionVersion = "0x1" TransactionV1WithQueryBit TransactionVersion = "0x100000000000000000000000000000001" TransactionV2 TransactionVersion = "0x2" TransactionV2WithQueryBit TransactionVersion = "0x100000000000000000000000000000002" TransactionV3 TransactionVersion = "0x3" TransactionV3WithQueryBit TransactionVersion = "0x100000000000000000000000000000003" )
type TransactionWithReceipt ¶ added in v0.7.0
type TransactionWithReceipt struct {
Transaction BlockTransaction `json:"transaction"`
Receipt TransactionReceipt `json:"receipt"`
}
type TxDetails ¶ added in v0.4.6
type TxDetails struct {
Nonce *felt.Felt
MaxFee *felt.Felt
Version TransactionVersion
}
TxDetails contains details needed for computing transaction hashes
type TxnExecutionStatus ¶ added in v0.4.4
type TxnExecutionStatus string
const ( TxnExecutionStatusSUCCEEDED TxnExecutionStatus = "SUCCEEDED" TxnExecutionStatusREVERTED TxnExecutionStatus = "REVERTED" )
func (TxnExecutionStatus) MarshalJSON ¶ added in v0.4.4
func (ts TxnExecutionStatus) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the TxnExecutionStatus.
It marshals the TxnExecutionStatus into a byte slice by quoting its string representation. The function returns the marshaled byte slice and a nil error.
Parameters:
none
Returns: - []byte: the JSON encoding of the TxnExecutionStatus - error: the error if there was an issue marshaling
func (TxnExecutionStatus) String ¶ added in v0.4.4
func (s TxnExecutionStatus) String() string
String returns the string representation of the TxnExecutionStatus.
Parameters:
none
Returns: - string: the string representation of the TxnExecutionStatus
func (*TxnExecutionStatus) UnmarshalJSON ¶ added in v0.4.4
func (ts *TxnExecutionStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON data into a TxnExecutionStatus struct.
Parameters: - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshalled Returns: - error: an error if the unmarshaling fails
type TxnFinalityStatus ¶ added in v0.4.4
type TxnFinalityStatus string
const ( TxnFinalityStatusAcceptedOnL1 TxnFinalityStatus = "ACCEPTED_ON_L1" TxnFinalityStatusAcceptedOnL2 TxnFinalityStatus = "ACCEPTED_ON_L2" )
func (TxnFinalityStatus) MarshalJSON ¶ added in v0.4.4
func (ts TxnFinalityStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshals the TxnFinalityStatus into JSON.
Parameters:
none
Returns: - []byte: a byte slice - error: an error if any
func (TxnFinalityStatus) String ¶ added in v0.4.4
func (s TxnFinalityStatus) String() string
String returns the string representation of the TxnFinalityStatus.
Parameters:
none
Returns: - string: the string representation of the TxnFinalityStatus
func (*TxnFinalityStatus) UnmarshalJSON ¶ added in v0.4.4
func (ts *TxnFinalityStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON data into a TxnFinalityStatus.
Parameters: - data: It takes a byte slice as a parameter, which represents the JSON data to be unmarshalled Returns: - error: an error if the unmarshaling fails
type TxnStatusResp ¶ added in v0.5.0
type TxnStatusResp struct {
FinalityStatus TxnStatus `json:"finality_status"`
ExecutionStatus TxnExecutionStatus `json:"execution_status,omitempty"`
FailureReason string `json:"failure_reason,omitempty"`
}
type U128 ¶ added in v0.6.0
type U128 string
64 bit integers, represented by hex string of length at most 32
type U64 ¶ added in v0.6.0
type U64 string
64 bit integers, represented by hex string of length at most 16
type UnknownTransaction ¶
type UnknownTransaction struct{ Transaction }
func (*UnknownTransaction) UnmarshalJSON ¶
func (txn *UnknownTransaction) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the JSON data into an UnknownTransaction object.
Parameters: - data: The JSON data to be unmarshalled Returns: - error: An error if the unmarshalling process fails
type WebsocketProvider ¶ added in v0.8.0
type WebsocketProvider interface {
SubscribeEvents(ctx context.Context, events chan<- *EmittedEvent, options *EventSubscriptionInput) (*client.ClientSubscription, error)
SubscribeNewHeads(ctx context.Context, headers chan<- *BlockHeader, blockID BlockID) (*client.ClientSubscription, error)
SubscribePendingTransactions(ctx context.Context, pendingTxns chan<- *SubPendingTxns, options *SubPendingTxnsInput) (*client.ClientSubscription, error)
SubscribeTransactionStatus(ctx context.Context, newStatus chan<- *NewTxnStatusResp, transactionHash *felt.Felt) (*client.ClientSubscription, error)
}
type WsProvider ¶ added in v0.8.0
type WsProvider struct {
// contains filtered or unexported fields
}
WsProvider provides the provider for websocket starknet.go/rpc implementation.
func NewWebsocketProvider ¶ added in v0.8.0
func NewWebsocketProvider(url string, options ...client.ClientOption) (*WsProvider, error)
NewWebsocketProvider creates a new Websocket rpc Provider instance.
func (*WsProvider) Close ¶ added in v0.8.0
func (p *WsProvider) Close()
Close closes the client, aborting any in-flight requests.
func (*WsProvider) SubscribeEvents ¶ added in v0.8.0
func (provider *WsProvider) SubscribeEvents(ctx context.Context, events chan<- *EmittedEvent, options *EventSubscriptionInput) (*client.ClientSubscription, error)
Events subscription. Creates a WebSocket stream which will fire events for new Starknet events with applied filters
Parameters:
- ctx: The context.Context object for controlling the function call
- events: The channel to send the new events to
- options: The optional input struct containing the optional filters. Set to nil if no filters are needed.
- fromAddress: Filter events by from_address which emitted the event
- keys: Per key (by position), designate the possible values to be matched for events to be returned. Empty array designates 'any' value
- blockID: The block to get notifications from, limited to 1024 blocks back. If empty, the latest block will be used
Returns:
- clientSubscription: The client subscription object, used to unsubscribe from the stream and to get errors
- error: An error, if any
func (*WsProvider) SubscribeNewHeads ¶ added in v0.8.0
func (provider *WsProvider) SubscribeNewHeads(ctx context.Context, headers chan<- *BlockHeader, blockID BlockID) (*client.ClientSubscription, error)
New block headers subscription. Creates a WebSocket stream which will fire events for new block headers
Parameters:
- ctx: The context.Context object for controlling the function call
- headers: The channel to send the new block headers to
- blockID (optional): The block to get notifications from, limited to 1024 blocks back. If empty, the latest block will be used
Returns:
- clientSubscription: The client subscription object, used to unsubscribe from the stream and to get errors
- error: An error, if any
func (*WsProvider) SubscribePendingTransactions ¶ added in v0.8.0
func (provider *WsProvider) SubscribePendingTransactions(ctx context.Context, pendingTxns chan<- *SubPendingTxns, options *SubPendingTxnsInput) (*client.ClientSubscription, error)
New Pending Transactions subscription Creates a WebSocket stream which will fire events when a new pending transaction is added. While there is no mempool, this notifies of transactions in the pending block.
Parameters:
- ctx: The context.Context object for controlling the function call
- pendingTxns: The channel to send the new pending transactions to
- options: The optional input struct containing the optional filters. Set to nil if no filters are needed.
Returns:
- clientSubscription: The client subscription object, used to unsubscribe from the stream and to get errors
- error: An error, if any
func (*WsProvider) SubscribeTransactionStatus ¶ added in v0.8.0
func (provider *WsProvider) SubscribeTransactionStatus(ctx context.Context, newStatus chan<- *NewTxnStatusResp, transactionHash *felt.Felt) (*client.ClientSubscription, error)
Transaction Status subscription. Creates a WebSocket stream which at first fires an event with the current known transaction status, followed by events for every transaction status update
Parameters:
- ctx: The context.Context object for controlling the function call
- newStatus: The channel to send the new transaction status to
- transactionHash: The transaction hash to fetch status updates for
Returns:
- clientSubscription: The client subscription object, used to unsubscribe from the stream and to get errors
- error: An error, if any
Source Files
¶
- block.go
- call.go
- chain.go
- client.go
- contract.go
- errors.go
- events.go
- executables.go
- provider.go
- trace.go
- transaction.go
- types.go
- types_block.go
- types_block_transaction.go
- types_broadcast_transaction.go
- types_contract.go
- types_event.go
- types_trace.go
- types_transaction.go
- types_transaction_interfaces.go
- types_transaction_receipt.go
- types_transaction_response.go
- version.go
- websocket.go
- write.go