Documentation ¶
Index ¶
- Variables
- func ContractAddress(callerAddress, classHash, salt *felt.Felt, constructorCallData []*felt.Felt) *felt.Felt
- func EventsBloom(receipts []*TransactionReceipt) *bloom.BloomFilter
- func MarshalBlockNumber(blockNumber uint64) []byte
- func NetworkBlockHashMetaInfo(network utils.Network) *blockHashMetaInfo
- func ParseBlockVersion(protocolVersion string) (*semver.Version, error)
- func TransactionHash(transaction Transaction, n utils.Network) (*felt.Felt, error)
- func VerifyBlockHash(b *Block, network utils.Network) error
- func VerifyClassHashes(classes map[felt.Felt]Class) error
- func VerifyTransactions(txs []Transaction, n utils.Network, protocolVersion string) error
- type Block
- type BuiltinInstanceCounter
- type Cairo0Class
- type Cairo1Class
- type Class
- type Contract
- func (c *Contract) ClassHash() (*felt.Felt, error)
- func (c *Contract) Nonce() (*felt.Felt, error)
- func (c *Contract) Purge() error
- func (c *Contract) Replace(classHash *felt.Felt) error
- func (c *Contract) Root() (*felt.Felt, error)
- func (c *Contract) Storage(key *felt.Felt) (*felt.Felt, error)
- func (c *Contract) UpdateNonce(nonce *felt.Felt) error
- func (c *Contract) UpdateStorage(diff []StorageDiff, cb OnValueChanged) error
- type DeclareTransaction
- type DeclaredClass
- type DeclaredV1Class
- type DeployAccountTransaction
- type DeployTransaction
- type DeployedContract
- type EntryPoint
- type Event
- type ExecutionResources
- type Header
- type History
- func (h *History) ContractClassHashAt(contractAddress *felt.Felt, height uint64) (*felt.Felt, error)
- func (h *History) ContractNonceAt(contractAddress *felt.Felt, height uint64) (*felt.Felt, error)
- func (h *History) ContractStorageAt(contractAddress, storageLocation *felt.Felt, height uint64) (*felt.Felt, error)
- func (h *History) DeleteContractClassHashLog(contractAddress *felt.Felt, height uint64) error
- func (h *History) DeleteContractNonceLog(contractAddress *felt.Felt, height uint64) error
- func (h *History) DeleteContractStorageLog(contractAddress, storageLocation *felt.Felt, height uint64) error
- func (h *History) LogContractClassHash(contractAddress, oldValue *felt.Felt, height uint64) error
- func (h *History) LogContractNonce(contractAddress, oldValue *felt.Felt, height uint64) error
- func (h *History) LogContractStorage(contractAddress, storageLocation, oldValue *felt.Felt, height uint64) error
- type InvokeTransaction
- type L1HandlerTransaction
- type L1Head
- type L1ToL2Message
- type L2ToL1Message
- type OnValueChanged
- type ReplacedClass
- type SierraEntryPoint
- type State
- func (s *State) Class(classHash *felt.Felt) (*DeclaredClass, error)
- func (s *State) ContractClassHash(addr *felt.Felt) (*felt.Felt, error)
- func (s *State) ContractIsAlreadyDeployedAt(addr *felt.Felt, blockNumber uint64) (bool, error)
- func (s *State) ContractNonce(addr *felt.Felt) (*felt.Felt, error)
- func (s *State) ContractStorage(addr, key *felt.Felt) (*felt.Felt, error)
- func (s *State) Revert(blockNumber uint64, update *StateUpdate) error
- func (s *State) Root() (*felt.Felt, error)
- func (s *State) Update(blockNumber uint64, update *StateUpdate, declaredClasses map[felt.Felt]Class) error
- type StateDiff
- type StateHistoryReader
- type StateReader
- type StateUpdate
- type StorageDiff
- type Transaction
- type TransactionReceipt
Constants ¶
This section is empty.
Variables ¶
var ( ErrContractNotDeployed = errors.New("contract not deployed") ErrContractAlreadyDeployed = errors.New("contract already deployed") )
var ErrCheckHeadState = errors.New("check head state")
Functions ¶
func ContractAddress ¶
func ContractAddress(callerAddress, classHash, salt *felt.Felt, constructorCallData []*felt.Felt) *felt.Felt
ContractAddress computes the address of a Starknet contract.
func EventsBloom ¶ added in v0.3.1
func EventsBloom(receipts []*TransactionReceipt) *bloom.BloomFilter
func MarshalBlockNumber ¶ added in v0.4.0
func NetworkBlockHashMetaInfo ¶ added in v0.5.0
func ParseBlockVersion ¶ added in v0.3.1
ParseBlockVersion computes the block version, defaulting to "0.0.0" for empty strings
func TransactionHash ¶ added in v0.4.0
func VerifyBlockHash ¶
VerifyBlockHash verifies the block hash. Due to bugs in Starknet alpha, not all blocks have verifiable hashes.
func VerifyTransactions ¶ added in v0.2.1
func VerifyTransactions(txs []Transaction, n utils.Network, protocolVersion string) error
Types ¶
type Block ¶
type Block struct { *Header Transactions []Transaction Receipts []*TransactionReceipt }
type BuiltinInstanceCounter ¶
type Cairo0Class ¶ added in v0.2.1
type Cairo0Class struct { Abi json.RawMessage // External functions defined in the class. Externals []EntryPoint // Functions that receive L1 messages. See // https://www.cairo-lang.org/docs/hello_starknet/l1l2.html#receiving-a-message-from-l1 L1Handlers []EntryPoint // Constructors for the class. Currently, only one is allowed. Constructors []EntryPoint // Base64 encoding of compressed Program Program string }
Cairo0Class unambiguously defines a Contract's semantics.
func (*Cairo0Class) Version ¶ added in v0.2.1
func (c *Cairo0Class) Version() uint64
type Cairo1Class ¶ added in v0.2.1
type Cairo1Class struct { Abi string AbiHash *felt.Felt EntryPoints struct { Constructor []SierraEntryPoint External []SierraEntryPoint L1Handler []SierraEntryPoint } Program []*felt.Felt ProgramHash *felt.Felt SemanticVersion string Compiled json.RawMessage }
Cairo1Class unambiguously defines a Contract's semantics.
func (*Cairo1Class) Hash ¶ added in v0.2.1
func (c *Cairo1Class) Hash() *felt.Felt
func (*Cairo1Class) Version ¶ added in v0.2.1
func (c *Cairo1Class) Version() uint64
type Class ¶
type Class interface {
Version() uint64
}
Class unambiguously defines a Contract's semantics.
type Contract ¶
type Contract struct { // Address that this contract instance is deployed to Address *felt.Felt // contains filtered or unexported fields }
Contract is an instance of a Class.
func DeployContract ¶ added in v0.2.1
DeployContract sets up the database for a new contract.
func NewContract ¶
NewContract creates a contract instance at the given address. Deploy should be called for contracts that were just deployed to the network.
func (*Contract) Nonce ¶
Nonce returns the amount transactions sent from this contract. Only account contracts can have a non-zero nonce.
func (*Contract) Purge ¶ added in v0.4.0
Purge eliminates the contract instance, deleting all associated data from storage assumes storage is cleared in revert process
func (*Contract) Replace ¶ added in v0.2.1
Replace replaces the class that the contract instantiates
func (*Contract) UpdateNonce ¶
UpdateNonce updates the nonce value in the database.
func (*Contract) UpdateStorage ¶
func (c *Contract) UpdateStorage(diff []StorageDiff, cb OnValueChanged) error
UpdateStorage applies a change-set to the contract storage.
type DeclareTransaction ¶
type DeclareTransaction struct { TransactionHash *felt.Felt // The class hash ClassHash *felt.Felt // The address of the account initiating the transaction. SenderAddress *felt.Felt // The maximum fee that the sender is willing to pay for the transaction. MaxFee *felt.Felt // Additional information given by the sender, used to validate the transaction. TransactionSignature []*felt.Felt // The transaction nonce. Nonce *felt.Felt // The transaction’s version. Possible values are 1 or 0. // When the fields that comprise a transaction change, // either with the addition of a new field or the removal of an existing field, // then the transaction version increases. // Transaction version 0 is deprecated and will be removed in a future version of Starknet. Version *felt.Felt // Version 2 fields CompiledClassHash *felt.Felt }
func (*DeclareTransaction) Hash ¶
func (d *DeclareTransaction) Hash() *felt.Felt
func (*DeclareTransaction) Signature ¶
func (d *DeclareTransaction) Signature() []*felt.Felt
type DeclaredClass ¶ added in v0.3.0
type DeclaredV1Class ¶ added in v0.2.1
type DeployAccountTransaction ¶
type DeployAccountTransaction struct { DeployTransaction // The maximum fee that the sender is willing to pay for the transaction. MaxFee *felt.Felt // Additional information given by the sender, used to validate the transaction. TransactionSignature []*felt.Felt // The transaction nonce. Nonce *felt.Felt }
func (*DeployAccountTransaction) Hash ¶
func (d *DeployAccountTransaction) Hash() *felt.Felt
func (*DeployAccountTransaction) Signature ¶
func (d *DeployAccountTransaction) Signature() []*felt.Felt
type DeployTransaction ¶
type DeployTransaction struct { TransactionHash *felt.Felt // A random number used to distinguish between different instances of the contract. ContractAddressSalt *felt.Felt // The address of the contract. ContractAddress *felt.Felt // The hash of the class which defines the contract’s functionality. ClassHash *felt.Felt // The arguments passed to the constructor during deployment. ConstructorCallData []*felt.Felt // The transaction’s version. Possible values are 1 or 0. // // When the fields that comprise a transaction change, // either with the addition of a new field or the removal of an existing field, // then the transaction version increases. // Transaction version 0 is deprecated and will be removed in a future version of Starknet. Version *felt.Felt }
func (*DeployTransaction) Hash ¶
func (d *DeployTransaction) Hash() *felt.Felt
func (*DeployTransaction) Signature ¶
func (d *DeployTransaction) Signature() []*felt.Felt
type EntryPoint ¶
type EntryPoint struct { // starknet_keccak hash of the function signature. Selector *felt.Felt // The offset of the instruction in the class's bytecode. Offset *felt.Felt }
EntryPoint uniquely identifies a Cairo function to execute.
type ExecutionResources ¶
type ExecutionResources struct { BuiltinInstanceCounter BuiltinInstanceCounter MemoryHoles uint64 Steps uint64 }
type Header ¶
type Header struct { // The hash of this block Hash *felt.Felt // The hash of this block’s parent ParentHash *felt.Felt // The number (height) of this block Number uint64 // The state commitment after this block GlobalStateRoot *felt.Felt // The Starknet address of the sequencer who created this block SequencerAddress *felt.Felt // The amount Transactions and Receipts stored in this block TransactionCount uint64 // The amount of events stored in transaction receipts EventCount uint64 // The time the sequencer created this block before executing transactions Timestamp uint64 // The version of the Starknet protocol used when creating this block ProtocolVersion string // Extraneous data that might be useful for running transactions ExtraData *felt.Felt // Bloom filter on the events emitted this block EventsBloom *bloom.BloomFilter // Amount of ETH charged per Gas spent GasPrice *felt.Felt }
type History ¶ added in v0.3.0
type History struct {
// contains filtered or unexported fields
}
func NewHistory ¶ added in v0.3.0
func NewHistory(txn db.Transaction) *History
func (*History) ContractClassHashAt ¶ added in v0.3.0
func (*History) ContractNonceAt ¶ added in v0.3.0
func (*History) ContractStorageAt ¶ added in v0.3.0
func (h *History) ContractStorageAt(contractAddress, storageLocation *felt.Felt, height uint64) (*felt.Felt, error)
ContractStorageAt returns the value of a storage location of the given contract at the height `height`
func (*History) DeleteContractClassHashLog ¶ added in v0.3.0
func (*History) DeleteContractNonceLog ¶ added in v0.3.0
func (*History) DeleteContractStorageLog ¶ added in v0.3.0
func (h *History) DeleteContractStorageLog(contractAddress, storageLocation *felt.Felt, height uint64) error
DeleteContractStorageLog deletes the log at the given height
func (*History) LogContractClassHash ¶ added in v0.3.0
func (*History) LogContractNonce ¶ added in v0.3.0
type InvokeTransaction ¶
type InvokeTransaction struct { TransactionHash *felt.Felt // The arguments that are passed to the validated and execute functions. CallData []*felt.Felt // Additional information given by the sender, used to validate the transaction. TransactionSignature []*felt.Felt // The maximum fee that the sender is willing to pay for the transaction MaxFee *felt.Felt // The address of the contract invoked by this transaction. ContractAddress *felt.Felt // When the fields that comprise a transaction change, // either with the addition of a new field or the removal of an existing field, // then the transaction version increases. Version *felt.Felt // Version 0 fields // The encoding of the selector for the function invoked (the entry point in the contract) EntryPointSelector *felt.Felt // Version 1 fields // The transaction nonce. Nonce *felt.Felt // The address of the sender of this transaction SenderAddress *felt.Felt }
func (*InvokeTransaction) Hash ¶
func (i *InvokeTransaction) Hash() *felt.Felt
func (*InvokeTransaction) Signature ¶
func (i *InvokeTransaction) Signature() []*felt.Felt
type L1HandlerTransaction ¶
type L1HandlerTransaction struct { TransactionHash *felt.Felt // The address of the contract. ContractAddress *felt.Felt // The encoding of the selector for the function invoked (the entry point in the contract) EntryPointSelector *felt.Felt // The transaction nonce. Nonce *felt.Felt // The arguments that are passed to the validated and execute functions. CallData []*felt.Felt // When the fields that comprise a transaction change, // either with the addition of a new field or the removal of an existing field, // then the transaction version increases. Version *felt.Felt }
func (*L1HandlerTransaction) Hash ¶
func (l *L1HandlerTransaction) Hash() *felt.Felt
func (*L1HandlerTransaction) Signature ¶
func (l *L1HandlerTransaction) Signature() []*felt.Felt
type L1ToL2Message ¶
type L2ToL1Message ¶
type OnValueChanged ¶ added in v0.3.0
type ReplacedClass ¶ added in v0.2.1
type SierraEntryPoint ¶ added in v0.2.1
type State ¶
type State struct { *History // contains filtered or unexported fields }
func NewState ¶
func NewState(txn db.Transaction) *State
func (*State) Class ¶ added in v0.3.0
func (s *State) Class(classHash *felt.Felt) (*DeclaredClass, error)
Class returns the class object corresponding to the given classHash
func (*State) ContractClassHash ¶ added in v0.2.1
ContractClassHash returns class hash of a contract at a given address.
func (*State) ContractIsAlreadyDeployedAt ¶ added in v0.3.0
ContractIsAlreadyDeployedAt returns if contract at given addr was deployed at blockNumber
func (*State) ContractNonce ¶ added in v0.2.1
ContractNonce returns nonce of a contract at a given address.
func (*State) ContractStorage ¶ added in v0.3.0
ContractStorage returns value of a key in the storage of the contract at the given address.
func (*State) Revert ¶ added in v0.4.0
func (s *State) Revert(blockNumber uint64, update *StateUpdate) error
func (*State) Update ¶
func (s *State) Update(blockNumber uint64, update *StateUpdate, declaredClasses map[felt.Felt]Class) error
Update applies a StateUpdate to the State object. State is not updated if an error is encountered during the operation. If update's old or new root does not match the state's old or new roots, [ErrMismatchedRoot] is returned.
type StateDiff ¶
type StateDiff struct { StorageDiffs map[felt.Felt][]StorageDiff Nonces map[felt.Felt]*felt.Felt DeployedContracts []DeployedContract DeclaredV0Classes []*felt.Felt DeclaredV1Classes []DeclaredV1Class ReplacedClasses []ReplacedClass }
type StateHistoryReader ¶ added in v0.3.0
type StateHistoryReader interface { StateReader ContractStorageAt(addr, key *felt.Felt, blockNumber uint64) (*felt.Felt, error) ContractNonceAt(addr *felt.Felt, blockNumber uint64) (*felt.Felt, error) ContractClassHashAt(addr *felt.Felt, blockNumber uint64) (*felt.Felt, error) ContractIsAlreadyDeployedAt(addr *felt.Felt, blockNumber uint64) (bool, error) }
type StateReader ¶ added in v0.3.0
type StateReader interface { ContractClassHash(addr *felt.Felt) (*felt.Felt, error) ContractNonce(addr *felt.Felt) (*felt.Felt, error) ContractStorage(addr, key *felt.Felt) (*felt.Felt, error) Class(classHash *felt.Felt) (*DeclaredClass, error) }
func NewStateSnapshot ¶ added in v0.3.0
func NewStateSnapshot(state StateHistoryReader, blockNumber uint64) StateReader
type StateUpdate ¶
type TransactionReceipt ¶
type TransactionReceipt struct { Fee *felt.Felt Events []*Event ExecutionResources *ExecutionResources L1ToL2Message *L1ToL2Message L2ToL1Message []*L2ToL1Message TransactionHash *felt.Felt Reverted bool RevertReason string }