Documentation
¶
Index ¶
- Constants
- Variables
- func NewError(resp *http.Response) error
- type Block
- type BlockOptions
- type Bytecode
- type Code
- type ContractAddresses
- type DeclareRequest
- type DeployAccountRequest
- type Error
- type Event
- type ExecutionResources
- type FunctionCall
- type FunctionInvocation
- type Gateway
- func (sg *Gateway) AccountNonce(ctx context.Context, address *felt.Felt) (*big.Int, error)
- func (sg *Gateway) Block(ctx context.Context, opts *BlockOptions) (*Block, error)
- func (sg *Gateway) BlockByHash(context.Context, string, string) (*Block, error)
- func (sg *Gateway) BlockByNumber(context.Context, *big.Int, string) (*Block, error)
- func (sg *Gateway) Call(ctx context.Context, call types.FunctionCall, blockHashOrTag string) ([]string, error)
- func (sg *Gateway) ChainID(context.Context) (string, error)
- func (sg *Gateway) Class(context.Context, string) (*rpc.ContractClass, error)
- func (sg *Gateway) ClassAt(context.Context, string) (*rpc.ContractClass, error)
- func (sg *Gateway) ClassByHash(ctx context.Context, hash string) (*rpc.ContractClass, error)
- func (sg *Gateway) ClassHashAt(ctx context.Context, address string) (*felt.Felt, error)
- func (sg *Gateway) CodeAt(ctx context.Context, contract string, blockNumber *big.Int) (*Code, error)
- func (sg *Gateway) ContractAddresses(ctx context.Context) (*ContractAddresses, error)
- func (sg *Gateway) Declare(ctx context.Context, contract rpc.ContractClass, declareRequest DeclareRequest) (resp types.AddDeclareResponse, err error)
- func (sg *Gateway) Deploy(ctx context.Context, contract rpc.ContractClass, ...) (resp types.AddDeployResponse, err error)
- func (sg *Gateway) DeployAccount(ctx context.Context, deployAccountRequest types.DeployAccountRequest) (resp types.AddDeployResponse, err error)
- func (sg *Gateway) EstimateFee(ctx context.Context, call types.FunctionInvoke, hash string) (*types.FeeEstimate, error)
- func (sg *Gateway) FullContract(ctx context.Context, contract string) (*rpc.ContractClass, error)
- func (sg *Gateway) Invoke(ctx context.Context, invoke types.FunctionInvoke) (*types.AddInvokeTransactionOutput, error)
- func (sg *Gateway) Nonce(ctx context.Context, contractAddress, blockHashOrTag string) (*big.Int, error)
- func (sg *Gateway) StateUpdate(ctx context.Context, opts *BlockOptions) (*StateUpdate, error)
- func (sg *Gateway) StorageAt(ctx context.Context, address string, key string, opts *StorageAtOptions) (string, error)
- func (gw *Gateway) Transaction(ctx context.Context, opts TransactionOptions) (*StarknetTransaction, error)
- func (gw *Gateway) TransactionByHash(ctx context.Context, hash string) (*Transaction, error)
- func (gw *Gateway) TransactionHash(ctx context.Context, id *big.Int) (string, error)
- func (gw *Gateway) TransactionID(ctx context.Context, hash string) (*big.Int, error)
- func (gw *Gateway) TransactionReceipt(ctx context.Context, txHash string) (*TransactionReceipt, error)
- func (gw *Gateway) TransactionStatus(ctx context.Context, opts TransactionStatusOptions) (*TransactionStatus, error)
- func (gw *Gateway) TransactionTrace(ctx context.Context, txHash string) (*TransactionTrace, error)
- func (gw *Gateway) WaitForTransaction(ctx context.Context, txHash string, interval, maxPoll int) (n int, receipt *TransactionReceipt, err error)
- type GatewayFunctionCall
- type GatewayProvider
- func (p *GatewayProvider) BlockByHash(ctx context.Context, hash, scope string) (*Block, error)
- func (p *GatewayProvider) BlockByNumber(ctx context.Context, number *big.Int, scope string) (*Block, error)
- func (p *GatewayProvider) Class(ctx context.Context, classHash string) (*rpc.ContractClass, error)
- func (p *GatewayProvider) ClassAt(ctx context.Context, contractAddress string) (*rpc.ContractClass, error)
- func (p *GatewayProvider) ClassHashAt(ctx context.Context, contractAddress string) (*felt.Felt, error)
- func (p *GatewayProvider) TransactionByHash(ctx context.Context, hash string) (*Transaction, error)
- type L1Message
- type L2Message
- type Option
- type StarkResp
- type StarknetTransaction
- type StateUpdate
- type StorageAtOptions
- type Transaction
- type TransactionFailureReason
- type TransactionOptions
- type TransactionReceipt
- type TransactionReceiptType
- type TransactionStatus
- type TransactionStatusOptions
- type TransactionTrace
Constants ¶
const ( INVOKE string = "INVOKE_FUNCTION" DEPLOY string = "DEPLOY" DEPLOY_ACCOUNT string = "DEPLOY_ACCOUNT" DECLARE string = "DECLARE" GOERLI_ID string = "SN_GOERLI" GOERLI2_ID string = "SN_GOERLI2" MAINNET_ID string = "SN_MAIN" LOCAL_BASE string = "http://localhost:5050" GOERLI_BASE string = "https://alpha4.starknet.io" GOERLI2_BASE string = "https://alpha4-2.starknet.io" MAINNET_BASE string = "https://alpha-mainnet.starknet.io" )
Variables ¶
var ErrInvalidBlock = errors.New("invalid block")
Functions ¶
Types ¶
type Block ¶
type Block struct {
BlockHash string `json:"block_hash"`
ParentBlockHash string `json:"parent_block_hash"`
BlockNumber int `json:"block_number"`
StateRoot string `json:"state_root"`
Status string `json:"status"`
Transactions []Transaction `json:"transactions"`
Timestamp int `json:"timestamp"`
TransactionReceipts []TransactionReceipt `json:"transaction_receipts"`
}
type BlockOptions ¶
type Code ¶
func (*Code) UnmarshalJSON ¶
type ContractAddresses ¶
type DeclareRequest ¶
type DeployAccountRequest ¶
type DeployAccountRequest types.DeployAccountRequest
func (DeployAccountRequest) MarshalJSON ¶
func (d DeployAccountRequest) MarshalJSON() ([]byte, error)
type Error ¶
type ExecutionResources ¶
type ExecutionResources struct {
NSteps int `json:"n_steps"`
BuiltinInstanceCounter struct {
PedersenBuiltin int `json:"pedersen_builtin"`
RangeCheckBuiltin int `json:"range_check_builtin"`
BitwiseBuiltin int `json:"bitwise_builtin"`
OutputBuiltin int `json:"output_builtin"`
EcdsaBuiltin int `json:"ecdsa_builtin"`
EcOpBuiltin int `json:"ec_op_builtin"`
} `json:"builtin_instance_counter"`
NMemoryHoles int `json:"n_memory_holes"`
}
type FunctionCall ¶
type FunctionCall types.FunctionCall
func (FunctionCall) MarshalJSON ¶
func (f FunctionCall) MarshalJSON() ([]byte, error)
type FunctionInvocation ¶
type FunctionInvocation struct {
CallerAddress string `json:"caller_address"`
ContractAddress string `json:"contract_address"`
Calldata []string `json:"calldata"`
CallType string `json:"call_type"`
ClassHash string `json:"class_hash"`
Selector string `json:"selector"`
EntryPointType string `json:"entry_point_type"`
Result []string `json:"result"`
ExecutionResources ExecutionResources `json:"execution_resources"`
InternalCalls []FunctionInvocation `json:"internal_calls"`
Events []Event `json:"events"`
Messages []interface{} `json:"messages"`
}
type Gateway ¶
type Gateway struct {
Base string `json:"base"`
Feeder string `json:"feeder"`
Gateway string `json:"gateway"`
ChainId string `json:"chainId"`
Client doer
// contains filtered or unexported fields
}
func (*Gateway) AccountNonce ¶
func (*Gateway) BlockByHash ¶
func (*Gateway) BlockByNumber ¶
func (*Gateway) Call ¶
func (sg *Gateway) Call(ctx context.Context, call types.FunctionCall, blockHashOrTag string) ([]string, error)
'call_contract' wrapper and can accept a blockId in the hash or height format
func (*Gateway) ClassByHash ¶
TODO: returns DeprecatedContractClass | SierraContractClass
func (*Gateway) ClassHashAt ¶
func (*Gateway) CodeAt ¶
func (sg *Gateway) CodeAt(ctx context.Context, contract string, blockNumber *big.Int) (*Code, error)
Gets a contracts code.
func (*Gateway) ContractAddresses ¶
func (sg *Gateway) ContractAddresses(ctx context.Context) (*ContractAddresses, error)
func (*Gateway) Declare ¶
func (sg *Gateway) Declare(ctx context.Context, contract rpc.ContractClass, declareRequest DeclareRequest) (resp types.AddDeclareResponse, err error)
'add_transaction' wrapper for compressing and declaring a contract class
func (*Gateway) Deploy ¶
func (sg *Gateway) Deploy(ctx context.Context, contract rpc.ContractClass, deployRequest rpc.DeployAccountTxn) (resp types.AddDeployResponse, err error)
'add_transaction' wrapper for compressing and deploying a compiled StarkNet contract
func (*Gateway) DeployAccount ¶
func (sg *Gateway) DeployAccount(ctx context.Context, deployAccountRequest types.DeployAccountRequest) (resp types.AddDeployResponse, err error)
'add_transaction' wrapper for deploying a compiled StarkNet account
func (*Gateway) EstimateFee ¶
func (sg *Gateway) EstimateFee(ctx context.Context, call types.FunctionInvoke, hash string) (*types.FeeEstimate, error)
func (*Gateway) FullContract ¶
func (*Gateway) Invoke ¶
func (sg *Gateway) Invoke(ctx context.Context, invoke types.FunctionInvoke) (*types.AddInvokeTransactionOutput, error)
'add_transaction' wrapper for invokation requests
func (*Gateway) StateUpdate ¶
func (sg *Gateway) StateUpdate(ctx context.Context, opts *BlockOptions) (*StateUpdate, error)
func (*Gateway) StorageAt ¶
func (sg *Gateway) StorageAt(ctx context.Context, address string, key string, opts *StorageAtOptions) (string, error)
Get a storage slots value.
func (*Gateway) Transaction ¶
func (gw *Gateway) Transaction(ctx context.Context, opts TransactionOptions) (*StarknetTransaction, error)
Gets the transaction information from a tx id.
func (*Gateway) TransactionByHash ¶
func (*Gateway) TransactionHash ¶
Gets the transaction hash from its id.
func (*Gateway) TransactionID ¶
Gets the transaction id from its hash.
func (*Gateway) TransactionReceipt ¶
func (gw *Gateway) TransactionReceipt(ctx context.Context, txHash string) (*TransactionReceipt, error)
Get transaction receipt for specific tx
func (*Gateway) TransactionStatus ¶
func (gw *Gateway) TransactionStatus(ctx context.Context, opts TransactionStatusOptions) (*TransactionStatus, error)
Gets the transaction status from a txn.
func (*Gateway) TransactionTrace ¶
func (*Gateway) WaitForTransaction ¶
type GatewayFunctionCall ¶
type GatewayFunctionCall struct {
FunctionCall
Signature []string `json:"signature"`
}
type GatewayProvider ¶
type GatewayProvider struct {
Gateway
}
func NewProvider ¶
func NewProvider(opts ...Option) *GatewayProvider
func (*GatewayProvider) BlockByHash ¶
func (*GatewayProvider) BlockByNumber ¶
func (*GatewayProvider) Class ¶
func (p *GatewayProvider) Class(ctx context.Context, classHash string) (*rpc.ContractClass, error)
func (*GatewayProvider) ClassAt ¶
func (p *GatewayProvider) ClassAt(ctx context.Context, contractAddress string) (*rpc.ContractClass, error)
func (*GatewayProvider) ClassHashAt ¶
func (*GatewayProvider) TransactionByHash ¶
func (p *GatewayProvider) TransactionByHash(ctx context.Context, hash string) (*Transaction, error)
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures how we set up the connection.
func WithBaseURL ¶
func WithErrorHandler ¶
WithErrorHandler returns an Option to set the error handler to be used.
func WithHttpClient ¶
type StarknetTransaction ¶
type StarknetTransaction struct {
TransactionIndex int `json:"transaction_index"`
BlockNumber int `json:"block_number"`
Transaction Transaction `json:"transaction"`
BlockHash string `json:"block_hash"`
Status string `json:"status"`
}
type StateUpdate ¶
type StateUpdate struct {
BlockHash string `json:"block_hash"`
NewRoot string `json:"new_root"`
OldRoot string `json:"old_root"`
StateDiff struct {
StorageDiffs map[string]interface{} `json:"storage_diffs"`
DeployedContracts []struct {
Address string `json:"address"`
ClassHash string `json:"class_hash"`
} `json:"deployed_contracts"`
} `json:"state_diff"`
}
type StorageAtOptions ¶
type Transaction ¶
type Transaction struct {
TransactionHash string `json:"transaction_hash,omitempty"`
ClassHash string `json:"class_hash,omitempty"`
ContractAddress string `json:"contract_address,omitempty"`
SenderAddress string `json:"sender_address,omitempty"`
EntryPointSelector string `json:"entry_point_selector,omitempty"`
Calldata []string `json:"calldata"`
Signature []string `json:"signature"`
EntryPointType string `json:"entry_point_type,omitempty"`
MaxFee string `json:"max_fee,omitempty"`
Nonce string `json:"nonce,omitempty"`
Version string `json:"version,omitempty"`
Type string `json:"type,omitempty"`
}
type TransactionOptions ¶
type TransactionReceipt ¶
type TransactionReceipt struct {
Status types.TransactionState `json:"status"`
BlockHash string `json:"block_hash"`
BlockNumber int `json:"block_number"`
TransactionFailureReason *TransactionFailureReason `json:"transaction_failure_reason,omitempty"`
TransactionIndex int `json:"transaction_index"`
TransactionHash string `json:"transaction_hash"`
L1ToL2ConsumedMessage struct {
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Selector string `json:"selector"`
Payload []string `json:"payload"`
} `json:"l1_to_l2_consumed_message"`
L2ToL1Messages []interface{} `json:"l2_to_l1_messages"`
Events []interface{} `json:"events"`
ExecutionResources ExecutionResources `json:"execution_resources"`
}
type TransactionReceiptType ¶
type TransactionReceiptType struct {
TransactionHash string `json:"txn_hash,omitempty"`
Status string `json:"status,omitempty"`
StatusData string `json:"status_data,omitempty"`
MessagesSent []*L1Message `json:"messages_sent,omitempty"`
L1OriginMessage *L2Message `json:"l1_origin_message,omitempty"`
Events []*Event `json:"events,omitempty"`
}
type TransactionStatus ¶
type TransactionTrace ¶
type TransactionTrace struct {
FunctionInvocation FunctionInvocation `json:"function_invocation"`
Signature []*felt.Felt `json:"signature"`
}