rpc

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 17 Imported by: 12

README

RPC implementation

starknet.go RPC implementation provides the RPC API to perform operations with Starknet. It is currently being tested and maintained up-to-date with Pathfinder and relies on go-ethereum to provide the JSON RPC 2.0 client implementation.

If you need starknet.go to support another API, open an issue on the project.

Testing the RPC API

To test the RPC API, you should simply go the the rpc directory and run go test like below:

cd rpc
go test -v .

We provide an additional -env flag to go test so that you can choose the environment you want to test. For instance, if you plan to test with the testnet, run:

cd rpc
go test -env testnet -v .

Supported environments are mock, testnet and mainnet. The support for devnet is planned but might require some dedicated condition since it is empty.

If you plan to specify an alternative URL to test the environment, you can set the INTEGRATION_BASE environment variable. In addition, tests load .env.${env}, and .env before relying on the environment variable. So for instanve if you want the URL to change only for the testnet environment, you could add the line below in .env.testnet:

INTEGRATION_BASE=http://localhost:9546

Documentation

Index

Constants

View Source
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

View Source
var (
	ErrFailedToReceiveTxn = &RPCError{
		Code:    1,
		Message: "Failed to write transaction",
	}
	ErrNoTraceAvailable = &RPCError{
		Code:    10,
		Message: "No trace available for transaction",
	}
	ErrContractNotFound = &RPCError{
		Code:    20,
		Message: "Contract not found",
	}
	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",
	}
	ErrTxnExec = &RPCError{
		Code:    41,
		Message: "Transaction execution error",
	}
	ErrInvalidContractClass = &RPCError{
		Code:    50,
		Message: "Invalid contract class",
	}
	ErrClassAlreadyDeclared = &RPCError{
		Code:    51,
		Message: "Class already declared",
	}
	ErrInvalidTransactionNonce = &RPCError{
		Code:    52,
		Message: "Invalid transaction nonce",
	}
	ErrInsufficientMaxFee = &RPCError{
		Code:    53,
		Message: "Max fee is smaller than the minimal transaction cost (validation plus fee transfer)",
	}
	ErrInsufficientAccountBalance = &RPCError{
		Code:    54,
		Message: "Account balance is smaller than the transaction's max_fee",
	}
	ErrValidationFailure = &RPCError{
		Code:    55,
		Message: "Account validation failed",
	}
	ErrCompilationFailed = &RPCError{
		Code:    56,
		Message: "Compilation failed",
	}
	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",
	}
)
View Source
var ErrInvalidBlockID = errors.New("invalid blockid")
View Source
var ErrNotImplemented = errors.New("not implemented")

Functions

func NewClient added in v0.4.6

func NewClient(url string) (*ethrpc.Client, error)

NewClient creates a new ethrpc.Client instance.

Parameters: - url: the URL of the RPC endpoint Returns: - *ethrpc.Client: a new ethrpc.Client - error: an error if any occurred

Types

type ABI

type ABI []ABIEntry

type ABIEntry

type ABIEntry interface {
	IsType() ABIType
}

type ABIType

type ABIType string
const (
	ABITypeConstructor ABIType = "constructor"
	ABITypeFunction    ABIType = "function"
	ABITypeL1Handler   ABIType = "l1_handler"
	ABITypeEvent       ABIType = "event"
	ABITypeStruct      ABIType = "struct"
)

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

type AddInvokeTransactionResponse struct {
	TransactionHash *felt.Felt `json:"transaction_hash"`
}

AddInvokeTransactionResponse provides the output for AddInvokeTransaction.

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

type BlockDeployTxn added in v0.4.4

type BlockDeployTxn struct {
	TransactionHash *felt.Felt `json:"transaction_hash"`
	DeployTxn
}

func (BlockDeployTxn) Hash added in v0.4.4

func (tx BlockDeployTxn) Hash() *felt.Felt

Hash returns the hash of the BlockDeployTxn.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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 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

func WithBlockHash(h *felt.Felt) BlockID

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

func WithBlockNumber(n uint64) BlockID

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

func WithBlockTag(tag string) BlockID

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

func (b BlockID) MarshalJSON() ([]byte, error)

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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 interface {
	Hash() *felt.Felt
}

type BlockTransactions added in v0.4.4

type BlockTransactions []BlockTransaction

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 {
	BlockStatus BlockStatus `json:"status"`
	BlockHeader
	BlockBodyWithReceipts
}

encoding/json doesn't support inlining fields

type BroadcastAddDeployTxnType added in v0.6.0

type BroadcastAddDeployTxnType interface{}

type BroadcastDeclareTxnType added in v0.6.0

type BroadcastDeclareTxnType interface{}

type BroadcastDeclareTxnV1 added in v0.6.0

type BroadcastDeclareTxnV1 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       NumAsHex                `json:"version"`
	Signature     []*felt.Felt            `json:"signature"`
	Nonce         *felt.Felt              `json:"nonce"`
	ContractClass DeprecatedContractClass `json:"contract_class"`
}

type BroadcastDeclareTxnV2 added in v0.6.0

type BroadcastDeclareTxnV2 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           NumAsHex      `json:"version"`
	Signature         []*felt.Felt  `json:"signature"`
	Nonce             *felt.Felt    `json:"nonce"`
	ContractClass     ContractClass `json:"contract_class"`
}

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           NumAsHex              `json:"version"`
	Signature         []*felt.Felt          `json:"signature"`
	Nonce             *felt.Felt            `json:"nonce"`
	ContractClass     *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 BroadcastDeployAccountTxn added in v0.5.0

type BroadcastDeployAccountTxn struct {
	DeployAccountTxn
}

type BroadcastDeployAccountTxnV3 added in v0.6.0

type BroadcastDeployAccountTxnV3 struct {
	DeployAccountTxnV3
}

type BroadcastInvokeTxnType added in v0.6.0

type BroadcastInvokeTxnType interface{}

type BroadcastInvokev0Txn added in v0.5.0

type BroadcastInvokev0Txn struct {
	InvokeTxnV0
}

type BroadcastInvokev1Txn added in v0.5.0

type BroadcastInvokev1Txn struct {
	InvokeTxnV1
}

type BroadcastInvokev3Txn added in v0.6.0

type BroadcastInvokev3Txn struct {
	InvokeTxnV3
}

type BroadcastTxn added in v0.5.0

type BroadcastTxn interface{}

type CallType added in v0.4.3

type CallType string
const (
	CallTypeLibraryCall CallType = "LIBRARY_CALL"
	CallTypeCall        CallType = "CALL"
	CallTypeDelegate    CallType = "DELEGATE"
)

type ClassOutput added in v0.4.3

type ClassOutput interface{}

type CommonTransactionReceipt

type CommonTransactionReceipt struct {
	// TransactionHash The hash identifying the transaction
	TransactionHash *felt.Felt `json:"transaction_hash"`
	// ActualFee The fee that was charged by the sequencer
	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 The events emitted as part of this transaction
	Events             []Event            `json:"events"`
	ExecutionResources ExecutionResources `json:"execution_resources"`
}

CommonTransactionReceipt Common properties for a transaction receipt

func (CommonTransactionReceipt) GetExecutionStatus added in v0.4.4

func (tr CommonTransactionReceipt) GetExecutionStatus() TxnExecutionStatus

GetExecutionStatus returns the execution status of the CommonTransactionReceipt.

Parameters:

none

Returns: - TxnExecutionStatus: the execution status

func (CommonTransactionReceipt) Hash

func (tr CommonTransactionReceipt) Hash() *felt.Felt

Hash returns the transaction hash associated with the CommonTransactionReceipt.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

type ComputationResources added in v0.7.0

type ComputationResources struct {
	// The number of Cairo steps used
	Steps int `json:"steps"`
	// The number of unused memory cells (each cell is roughly equivalent to a step)
	MemoryHoles int `json:"memory_holes,omitempty"`
	// The number of RANGE_CHECK builtin instances
	RangeCheckApps int `json:"range_check_builtin_applications,omitempty"`
	// The number of Pedersen builtin instances
	PedersenApps int `json:"pedersen_builtin_applications,omitempty"`
	// The number of Poseidon builtin instances
	PoseidonApps int `json:"poseidon_builtin_applications,omitempty"`
	// The number of EC_OP builtin instances
	ECOPApps int `json:"ec_op_builtin_applications,omitempty"`
	// The number of ECDSA builtin instances
	ECDSAApps int `json:"ecdsa_builtin_applications,omitempty"`
	// The number of BITWISE builtin instances
	BitwiseApps int `json:"bitwise_builtin_applications,omitempty"`
	// The number of KECCAK builtin instances
	KeccakApps int `json:"keccak_builtin_applications,omitempty"`
	// The number of accesses to the segment arena
	SegmentArenaBuiltin int `json:"segment_arena_builtin,omitempty"`
}

func (*ComputationResources) Validate added in v0.7.0

func (er *ComputationResources) Validate() bool

Validate checks if the fields are non-zero (to match the starknet-specs)

type ContractClass

type ContractClass struct {
	// The list of Sierra instructions of which the program consists
	SierraProgram []*felt.Felt `json:"sierra_program"`

	// The version of the contract class object. Currently, the Starknet OS supports version 0.1.0
	ContractClassVersion string `json:"contract_class_version"`

	EntryPointsByType EntryPointsByType `json:"entry_points_by_type"`

	ABI string `json:"abi,omitempty"`
}

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

type DataAvailability struct {
	// the gas consumed by this transaction's data, 0 if it uses data gas for DA
	L1Gas uint `json:"l1_gas"`
	// the data gas consumed by this transaction's data, 0 if it uses gas for DA
	L1DataGas uint `json:"l1_data_gas"`
}

type DataAvailabilityMode added in v0.6.0

type DataAvailabilityMode string
const (
	DAModeL1 DataAvailabilityMode = "L1"
	DAModeL2 DataAvailabilityMode = "L2"
)

func (*DataAvailabilityMode) UInt64 added in v0.6.0

func (da *DataAvailabilityMode) UInt64() (uint64, error)

type DeclareTransactionReceipt

type DeclareTransactionReceipt CommonTransactionReceipt

DeclareTransactionReceipt Declare Transaction Receipt

func (DeclareTransactionReceipt) GetExecutionStatus added in v0.4.4

func (tr DeclareTransactionReceipt) GetExecutionStatus() TxnExecutionStatus

GetExecutionStatus returns the execution status of the DeclareTransactionReceipt function.

Parameters:

none

Returns: - TxnExecutionStatus: the execution status

func (DeclareTransactionReceipt) Hash

func (tr DeclareTransactionReceipt) Hash() *felt.Felt

Hash returns the transaction hash.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

type DeclareTxnTrace added in v0.4.3

type DeclareTxnTrace struct {
	ValidateInvocation    FnInvocation       `json:"validate_invocation"`
	FeeTransferInvocation FnInvocation       `json:"fee_transfer_invocation"`
	StateDiff             StateDiff          `json:"state_diff"`
	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 DeployAccountTransactionReceipt

type DeployAccountTransactionReceipt struct {
	CommonTransactionReceipt
	// ContractAddress The address of the deployed contract
	ContractAddress *felt.Felt `json:"contract_address"`
}

DeployAccountTransactionReceipt Deploy Account Transaction Receipt

func (DeployAccountTransactionReceipt) GetExecutionStatus added in v0.4.4

func (tr DeployAccountTransactionReceipt) GetExecutionStatus() TxnExecutionStatus

GetExecutionStatus returns the execution status of the DeployAccountTransactionReceipt.

Parameters:

none

Returns: - *TxnExecutionStatus: the execution status

func (DeployAccountTransactionReceipt) Hash added in v0.4.3

Hash returns the transaction hash for the given DeployAccountTransactionReceipt.

Parameters:

none

Returns: - *felt.Felt: the transaction 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"`
	//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"`
	StateDiff             StateDiff          `json:"state_diff"`
	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 DeployTransactionReceipt

type DeployTransactionReceipt struct {
	CommonTransactionReceipt
	// The address of the deployed contract
	ContractAddress *felt.Felt `json:"contract_address"`
}

DeployTransactionReceipt Deploy Transaction Receipt

func (DeployTransactionReceipt) GetExecutionStatus added in v0.4.4

func (tr DeployTransactionReceipt) GetExecutionStatus() TxnExecutionStatus

GetExecutionStatus returns the execution status of the DeployTransactionReceipt.

Parameters:

none

Returns: - TxnExecutionStatus: the execution status

func (DeployTransactionReceipt) Hash added in v0.4.3

func (tr DeployTransactionReceipt) Hash() *felt.Felt

Hash returns the transaction hash of the DeployTransactionReceipt.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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

type DeprecatedCairoEntryPoint struct {
	// The offset of the entry point in the program
	Offset NumAsHex `json:"offset"`
	// A unique  identifier of the entry point (function) in the program
	Selector *felt.Felt `json:"selector"`
}

type DeprecatedContractClass added in v0.4.3

type DeprecatedContractClass struct {
	// Program A base64 representation of the compressed program code
	Program string `json:"program"`

	DeprecatedEntryPointsByType DeprecatedEntryPointsByType `json:"entry_points_by_type"`

	ABI *ABI `json:"abi,omitempty"`
}

func (*DeprecatedContractClass) UnmarshalJSON added in v0.4.3

func (c *DeprecatedContractClass) UnmarshalJSON(content []byte) error

UnmarshalJSON unmarshals the JSON content into the DeprecatedContractClass struct.

It takes a byte array `content` as a parameter and returns an error if there is any. The function processes the `program` field in the JSON object. If `program` is a string, it is assigned to the `Program` field in the struct. Otherwise, it is encoded and assigned to the `Program` field. The function then processes the `entry_points_by_type` field in the JSON object. The value is unmarshaled into the `DeprecatedEntryPointsByType` field in the struct. Finally, the function processes the `abi` field in the JSON object. If it is missing, the function returns nil. Otherwise, it unmarshals the value into a slice of interfaces. For each element in the slice, it checks the type and assigns it to the appropriate field in the `ABI` field in the struct.

Parameters: - content: byte array Returns: - error: error if there is any

type DeprecatedEntryPointsByType added in v0.4.3

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

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 EntryPointsByType

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

type Event

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

type EventABIEntry

type EventABIEntry struct {
	// The event type
	Type ABIType `json:"type"`

	// The event name
	Name string `json:"name"`

	Keys []TypedParameter `json:"keys"`

	Data []TypedParameter `json:"data"`
}

func (*EventABIEntry) IsType

func (e *EventABIEntry) IsType() ABIType

IsType returns the ABIType of the EventABIEntry.

Parameters:

none

Returns: - ABIType: the ABIType

type EventChunk added in v0.4.3

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

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 EventsInput

type EventsInput struct {
	EventFilter
	ResultPageRequest
}

type ExecInvocation added in v0.5.0

type ExecInvocation struct {
	FunctionInvocation FnInvocation `json:"function_invocation,omitempty"`
	RevertReason       string       `json:"revert_reason,omitempty"`
}

type ExecutionResources added in v0.5.0

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

The resources consumed by the transaction, includes both computation and data.

type FeeEstimate

type FeeEstimate struct {
	// The Ethereum gas consumption of the transaction
	GasConsumed *felt.Felt `json:"gas_consumed"`

	// The gas price (in wei or fri, depending on the tx version) that was used in the cost estimation.
	GasPrice *felt.Felt `json:"gas_price"`

	// The Ethereum data gas consumption of the transaction.
	DataGasConsumed *felt.Felt `json:"data_gas_consumed"`

	// The data gas price (in wei or fri, depending on the tx version) that was used in the cost estimation.
	DataGasPrice *felt.Felt `json:"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"`
}

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
	// https://github.com/starkware-libs/starknet-specs/blob/v0.7.0-rc0/api/starknet_trace_api_openrpc.json#L374C1-L374C29
	ComputationResources ComputationResources `json:"execution_resources"`
}

type FunctionABIEntry

type FunctionABIEntry struct {
	// The function type
	Type ABIType `json:"type"`

	// The function name
	Name string `json:"name"`

	StateMutability FunctionStateMutability `json:"stateMutability,omitempty"`

	Inputs []TypedParameter `json:"inputs"`

	Outputs []TypedParameter `json:"outputs"`
}

func (*FunctionABIEntry) IsType

func (f *FunctionABIEntry) IsType() ABIType

IsType returns the ABIType of the FunctionABIEntry.

Parameters:

none

Returns: - ABIType: the ABIType

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

type FunctionStateMutability string
const (
	FuncStateMutVIEW FunctionStateMutability = "view"
)

type InvokeTransactionReceipt

type InvokeTransactionReceipt CommonTransactionReceipt

InvokeTransactionReceipt Invoke Transaction Receipt

func (InvokeTransactionReceipt) GetExecutionStatus added in v0.4.4

func (tr InvokeTransactionReceipt) GetExecutionStatus() TxnExecutionStatus

GetExecutionStatus returns the execution status of the InvokeTransactionReceipt.

Parameters:

none

Returns: - TxnExecutionStatus: the execution status

func (InvokeTransactionReceipt) Hash

func (tr InvokeTransactionReceipt) Hash() *felt.Felt

Hash returns the hash of the invoke transaction receipt.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

type InvokeTxnTrace added in v0.4.3

type InvokeTxnTrace struct {
	ValidateInvocation FnInvocation `json:"validate_invocation"`
	//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"`
	StateDiff             StateDiff          `json:"state_diff"`
	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
const (
	L1DAModeBlob L1DAMode = iota
	L1DAModeCalldata
)

func (L1DAMode) MarshalJSON added in v0.7.0

func (mode L1DAMode) MarshalJSON() ([]byte, error)

func (L1DAMode) String added in v0.7.0

func (mode L1DAMode) String() string

func (*L1DAMode) UnmarshalJSON added in v0.7.0

func (mode *L1DAMode) UnmarshalJSON(b []byte) error

type L1HandlerTransactionReceipt

type L1HandlerTransactionReceipt CommonTransactionReceipt

L1HandlerTransactionReceipt L1 Handler Transaction Receipt

func (L1HandlerTransactionReceipt) GetExecutionStatus added in v0.4.4

func (tr L1HandlerTransactionReceipt) GetExecutionStatus() TxnExecutionStatus

GetExecutionStatus returns the execution status of the L1HandlerTransactionReceipt.

Parameters:

none

Returns: - TxnExecutionStatus: the execution status

func (L1HandlerTransactionReceipt) Hash

Hash returns the transaction hash.

Parameters:

none

Returns: - *felt.Felt: the transaction hash

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"`
	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 Member

type Member struct {
	TypedParameter
	Offset int64 `json:"offset"`
}

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 NumAsHex

type NumAsHex string

An integer number in hex format (0x...)

type OrderedEvent added in v0.5.0

type OrderedEvent struct {
	// The order of the event within the transaction
	Order int `json:"order"`
	Event Event
}

type OrderedMsg added in v0.5.0

type OrderedMsg struct {
	// The order of the message within the transaction
	Order   int `json:"order"`
	MsgToL1 MsgToL1
}

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"`
	// 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) (*Provider, error)

NewProvider creates a new rpc Provider instance.

func (*Provider) AddDeclareTransaction

func (provider *Provider) AddDeclareTransaction(ctx context.Context, declareTransaction BroadcastDeclareTxnType) (*AddDeclareTransactionResponse, *RPCError)

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 BroadcastAddDeployTxnType) (*AddDeployAccountTransactionResponse, *RPCError)

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 BroadcastInvokeTxnType) (*AddInvokeTransactionResponse, *RPCError)

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, *RPCError)

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

func (provider *Provider) BlockNumber(ctx context.Context) (uint64, *RPCError)

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, *RPCError)

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{}, *RPCError)

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{}, *RPCError)

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

func (provider *Provider) BlockWithTxs(ctx context.Context, blockID BlockID) (interface{}, *RPCError)

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, *RPCError)

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

func (provider *Provider) ChainID(ctx context.Context) (string, *RPCError)

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, *RPCError)

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, *RPCError)

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, *RPCError)

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) EstimateFee

func (provider *Provider) EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, blockID BlockID) ([]FeeEstimate, *RPCError)

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. For v0-2 transactions the estimate is given in wei, and for v3 transactions it is given in fri.

func (*Provider) EstimateMessageFee added in v0.4.4

func (provider *Provider) EstimateMessageFee(ctx context.Context, msg MsgFromL1, blockID BlockID) (*FeeEstimate, *RPCError)

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: - *FeeEstimate: 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, *RPCError)

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) GetTransactionStatus added in v0.5.0

func (provider *Provider) GetTransactionStatus(ctx context.Context, transactionHash *felt.Felt) (*TxnStatusResp, *RPCError)

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, *RPCError)

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 []Transaction, simulationFlags []SimulationFlag) ([]SimulatedTransaction, *RPCError)

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.

func (*Provider) SpecVersion added in v0.5.0

func (provider *Provider) SpecVersion(ctx context.Context) (string, *RPCError)

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, *RPCError)

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, *RPCError)

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, *RPCError)

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, *RPCError)

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, *RPCError)

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) (Transaction, *RPCError)

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: - Transaction: The retrieved Transaction object - error: An error, if any

func (*Provider) TransactionByHash

func (provider *Provider) TransactionByHash(ctx context.Context, hash *felt.Felt) (Transaction, *RPCError)

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: - Transaction: The retrieved Transaction - error: An error if any

func (*Provider) TransactionReceipt

func (provider *Provider) TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (*TransactionReceiptWithBlockInfo, *RPCError)

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 RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

func Err added in v0.4.4

func Err(code int, data any) *RPCError

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) Error

func (e *RPCError) Error() string

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"
)

type ResourceBounds added in v0.6.0

type ResourceBounds struct {
	// The max amount of the resource that can be used in the tx
	MaxAmount U64 `json:"max_amount"`
	// The max price per unit of this resource for this tx
	MaxPricePerUnit U128 `json:"max_price_per_unit"`
}

func (ResourceBounds) Bytes added in v0.6.0

func (rb ResourceBounds) Bytes(resource Resource) ([]byte, error)

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 L2 gas used in this tx
	L2Gas ResourceBounds `json:"l2_gas"`
}

type ResourcePrice added in v0.5.0

type ResourcePrice struct {
	// the price of one unit of the given resource, denominated in fri (10^-18 strk)
	PriceInFRI *felt.Felt `json:"price_in_strk,omitempty"`
	// The price of one unit of the given resource, denominated in wei
	PriceInWei *felt.Felt `json:"price_in_wei"`
}

type ResultPageRequest

type ResultPageRequest struct {
	// a pointer to the last element of the delivered page, use this token in a subsequent query to obtain the next page
	ContinuationToken string `json:"continuation_token,omitempty"`
	ChunkSize         int    `json:"chunk_size"`
}

type RpcProvider added in v0.4.6

type RpcProvider interface {
	AddInvokeTransaction(ctx context.Context, invokeTxn BroadcastInvokeTxnType) (*AddInvokeTransactionResponse, *RPCError)
	AddDeclareTransaction(ctx context.Context, declareTransaction BroadcastDeclareTxnType) (*AddDeclareTransactionResponse, *RPCError)
	AddDeployAccountTransaction(ctx context.Context, deployAccountTransaction BroadcastAddDeployTxnType) (*AddDeployAccountTransactionResponse, *RPCError)
	BlockHashAndNumber(ctx context.Context) (*BlockHashAndNumberOutput, *RPCError)
	BlockNumber(ctx context.Context) (uint64, *RPCError)
	BlockTransactionCount(ctx context.Context, blockID BlockID) (uint64, *RPCError)
	BlockWithTxHashes(ctx context.Context, blockID BlockID) (interface{}, *RPCError)
	BlockWithTxs(ctx context.Context, blockID BlockID) (interface{}, *RPCError)
	Call(ctx context.Context, call FunctionCall, block BlockID) ([]*felt.Felt, *RPCError)
	ChainID(ctx context.Context) (string, *RPCError)
	Class(ctx context.Context, blockID BlockID, classHash *felt.Felt) (ClassOutput, *RPCError)
	ClassAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (ClassOutput, *RPCError)
	ClassHashAt(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, *RPCError)
	EstimateFee(ctx context.Context, requests []BroadcastTxn, simulationFlags []SimulationFlag, blockID BlockID) ([]FeeEstimate, *RPCError)
	EstimateMessageFee(ctx context.Context, msg MsgFromL1, blockID BlockID) (*FeeEstimate, *RPCError)
	Events(ctx context.Context, input EventsInput) (*EventChunk, *RPCError)
	BlockWithReceipts(ctx context.Context, blockID BlockID) (interface{}, *RPCError)
	GetTransactionStatus(ctx context.Context, transactionHash *felt.Felt) (*TxnStatusResp, *RPCError)
	Nonce(ctx context.Context, blockID BlockID, contractAddress *felt.Felt) (*felt.Felt, *RPCError)
	SimulateTransactions(ctx context.Context, blockID BlockID, txns []Transaction, simulationFlags []SimulationFlag) ([]SimulatedTransaction, *RPCError)
	StateUpdate(ctx context.Context, blockID BlockID) (*StateUpdateOutput, *RPCError)
	StorageAt(ctx context.Context, contractAddress *felt.Felt, key string, blockID BlockID) (string, *RPCError)
	SpecVersion(ctx context.Context) (string, *RPCError)
	Syncing(ctx context.Context) (*SyncStatus, *RPCError)
	TraceBlockTransactions(ctx context.Context, blockID BlockID) ([]Trace, *RPCError)
	TransactionByBlockIdAndIndex(ctx context.Context, blockID BlockID, index uint64) (Transaction, *RPCError)
	TransactionByHash(ctx context.Context, hash *felt.Felt) (Transaction, *RPCError)
	TransactionReceipt(ctx context.Context, transactionHash *felt.Felt) (*TransactionReceiptWithBlockInfo, *RPCError)
	TraceTransaction(ctx context.Context, transactionHash *felt.Felt) (TxnTrace, *RPCError)
}

type SierraEntryPoint added in v0.4.3

type SierraEntryPoint struct {
	// The index of the function in the program
	FunctionIdx int `json:"function_idx"`
	// A unique  identifier of the entry point (function) in the program
	Selector *felt.Felt `json:"selector"`
}

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            []Transaction    `json:"transactions"`
	BlockID         BlockID          `json:"block_id"`
	SimulationFlags []SimulationFlag `json:"simulation_flags"`
}

type SimulateTransactionOutput added in v0.4.3

type SimulateTransactionOutput struct {
	Txns []SimulatedTransaction `json:"result"`
}

The execution trace and consumed resources of the required transactions

type SimulatedTransaction added in v0.4.3

type SimulatedTransaction struct {
	TxnTrace `json:"transaction_trace"`
	FeeEstimate
}

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 StorageEntry struct {
	Key   *felt.Felt `json:"key"`
	Value *felt.Felt `json:"value"`
}

type StructABIEntry

type StructABIEntry struct {
	// The event type
	Type ABIType `json:"type"`

	// The event name
	Name string `json:"name"`

	// todo(minumum size should be 1)
	Size uint64 `json:"size"`

	Members []Member `json:"members"`
}

func (*StructABIEntry) IsType

func (s *StructABIEntry) IsType() ABIType

IsType returns the ABIType of the StructABIEntry.

Parameters:

none

Returns: - ABIType: the ABIType

type SyncStatus

type SyncStatus struct {
	SyncStatus        bool       // todo(remove? not in spec)
	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"`
}

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

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

type Transaction

type Transaction interface {
	GetType() TransactionType
}

type TransactionReceipt

type TransactionReceipt interface {
	Hash() *felt.Felt
	GetExecutionStatus() TxnExecutionStatus
}

type TransactionReceiptWithBlockInfo added in v0.7.0

type TransactionReceiptWithBlockInfo struct {
	TransactionReceipt
	BlockHash   *felt.Felt `json:"block_hash,omitempty"`
	BlockNumber uint       `json:"block_number,omitempty"`
}

type TransactionType

type TransactionType string

TODO: check how we can move that type up in starknet.go/types

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.

Parameters:

none

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"
)

func (*TransactionVersion) BigInt

func (v *TransactionVersion) BigInt() (*big.Int, error)

BigInt returns a big integer corresponding to the transaction version.

Parameters:

none

Returns: - *big.Int: a pointer to a big.Int - error: an error if the conversion fails

type TransactionWithReceipt added in v0.7.0

type TransactionWithReceipt struct {
	Transaction UnknownTransaction        `json:"transaction"`
	Receipt     UnknownTransactionReceipt `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 TxnStatus added in v0.5.0

type TxnStatus string

The finality status of the transaction, including the case the txn is still in the mempool or failed validation during the block construction phase

const (
	TxnStatus_Received       TxnStatus = "RECEIVED"
	TxnStatus_Rejected       TxnStatus = "REJECTED"
	TxnStatus_Accepted_On_L2 TxnStatus = "ACCEPTED_ON_L2"
	TxnStatus_Accepted_On_L1 TxnStatus = "ACCEPTED_ON_L1"
)

type TxnStatusResp added in v0.5.0

type TxnStatusResp struct {
	ExecutionStatus TxnExecutionStatus `json:"execution_status,omitempty"`
	FinalityStatus  TxnStatus          `json:"finality_status"`
}

type TxnTrace added in v0.4.3

type TxnTrace interface{}

type TypedParameter

type TypedParameter struct {
	// The parameter's name
	Name string `json:"name"`

	// The parameter's type
	Type string `json:"type"`
}

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

func (U64) ToUint64 added in v0.6.0

func (u U64) ToUint64() (uint64, error)

ToUint64 converts the U64 type to a uint64.

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 UnknownTransactionReceipt

type UnknownTransactionReceipt struct{ TransactionReceipt }

func (*UnknownTransactionReceipt) UnmarshalJSON

func (tr *UnknownTransactionReceipt) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the given JSON data into an UnknownTransactionReceipt.

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

Jump to

Keyboard shortcuts

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