starknet

package
v0.0.0-...-d2aac13 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockLatest  BlockId = "latest"
	BlockPending BlockId = "pending"

	Mainnet StarknetNetwork = "mainnet"
	Goerli  StarknetNetwork = "goerli"
	Sepolia StarknetNetwork = "sepolia"
)

Variables

View Source
var (
	Zero = FeltFromString("0x0")
	One  = FeltFromString("0x1")
	Two  = FeltFromString("0x2")
)

Functions

func DecodeGob

func DecodeGob[T any](data []byte) (*T, error)

func DecodeResponseToStruct

func DecodeResponseToStruct[T any](data []felt.Felt, s T) error

func DecodeSlice

func DecodeSlice[T any](data [][]byte) ([]*T, error)

func DecodeToString

func DecodeToString(feltArr []felt.Felt) string

func DeserializeResponse

func DeserializeResponse[T any](data []byte, into *T) (*T, error)

func EncodeGob

func EncodeGob[T any](data *T) ([]byte, error)

func EnsureStarkFelt

func EnsureStarkFelt(felt string) string

EnsureStarkFelt adds 0 padding to left side of felt

func FeltArrToBytesArr

func FeltArrToBytesArr(feltArr []felt.Felt) []byte

func FeltFromString

func FeltFromString(s string) *felt.Felt

func FeltFromUint64

func FeltFromUint64(i uint64) *felt.Felt

func HexStringToUint64

func HexStringToUint64(s string) uint64

func StarknetKeccak

func StarknetKeccak(b []byte) (*felt.Felt, error)

encode storage variable name to felt

Types

type BlockId

type BlockId string

type Event

type Event struct {
	RecordedAt  time.Time `json:"recorded_at"`
	EventId     string    `json:"event_id"`
	FromAddress string    `json:"from_address"`
	Keys        []string  `json:"keys"`
	Data        []string  `json:"data"`
}

type ExecutionResources

type ExecutionResources struct {
	ActualFee              string `json:"actual_fee"`
	BuiltinInstanceCounter struct {
		RangeCheckBuiltin uint `json:"range_check_builtin"`
		PedersenBuiltin   uint `json:"pedersen_builtin"`
		BitwiseBuiltin    uint `json:"bitwise_builtin"`
		OutputBuiltin     uint `json:"output_builtin"`
		EcdsaBuiltin      uint `json:"ecdsa_builtin"`
		EcOpBuiltin       uint `json:"ec_op_builtin"`
	} `json:"builtin_instance_counter"`
	NSteps       uint `json:"n_steps"`
	NMemoryHoles uint `json:"n_memory_holes"`
}

type FeederGatewayClient

type FeederGatewayClient struct {
	// contains filtered or unexported fields
}

func NewFeederGatewayClient

func NewFeederGatewayClient(baseUrl string) *FeederGatewayClient

func NewFeederGatewayClientFromEnv

func NewFeederGatewayClientFromEnv(env string) *FeederGatewayClient

func NewMainnetFeederGatewayClient

func NewMainnetFeederGatewayClient() *FeederGatewayClient

func NewSepoliaFeederGatewayClient

func NewSepoliaFeederGatewayClient() *FeederGatewayClient

func (FeederGatewayClient) Get

func (c FeederGatewayClient) Get(path string) ([]byte, error)

func (*FeederGatewayClient) GetBlock

func (c *FeederGatewayClient) GetBlock(blockNumber uint64) (*GetBlockResponse, error)

type GetBlockResponse

type GetBlockResponse struct {
	BlockHash           string               `json:"block_hash"`
	ParentBlockHash     string               `json:"parent_block_hash"`
	StateRoot           string               `json:"state_root"`
	Status              string               `json:"status"`
	GasPrice            string               `json:"gas_price"`
	SequencerAddress    string               `json:"sequencer_address"`
	StarknetVersion     string               `json:"starknet_version"`
	Transactions        []Transaction        `json:"transactions"`
	TransactionReceipts []TransactionReceipt `json:"transaction_receipts"`
	BlockNumber         uint64               `json:"block_number"`
	Timestamp           uint64               `json:"timestamp"`
}

type JsonRpcStarknetClient

type JsonRpcStarknetClient struct {
	Client   *http.Client
	Endpoint string
}

func GoerliJsonRpcStarknetClient

func GoerliJsonRpcStarknetClient() *JsonRpcStarknetClient

Create goerli json rpc client

func MainnetJsonRpcStarknetClient

func MainnetJsonRpcStarknetClient() *JsonRpcStarknetClient

Create mainnet json rpc client

func NewJsonRpcStarknetClient

func NewJsonRpcStarknetClient(endpoint string) *JsonRpcStarknetClient

func SepoliaJsonRpcStarknetClient

func SepoliaJsonRpcStarknetClient() *JsonRpcStarknetClient

Create sepolia json rpc client

func (*JsonRpcStarknetClient) Call

func (c *JsonRpcStarknetClient) Call(address string, method string, params []felt.Felt) ([]felt.Felt, error)

type L2ToL1Message

type L2ToL1Message struct {
	FromAddress string   `json:"from_address"`
	ToAddress   string   `json:"to_address"`
	Payload     []string `json:"payload"`
}

type SlotUri

type SlotUri struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Image       string `json:"image"`
	ExternalUrl string `json:"external_url"`
	YoutubeUrl  string `json:"youtube_url"`
	Attributes  []struct {
		Value       interface{} `json:"value,string"`
		DisplayType string      `json:"display_type"`
		TraitType   string      `json:"trait_type"`
	} `json:"attributes"`
}

type StarknetNetwork

type StarknetNetwork string

type StarknetRpcClient

type StarknetRpcClient interface {
	Call(address string, method string, params []felt.Felt) ([]felt.Felt, error)
}

type Transaction

type Transaction struct {
	TransactionHash string   `json:"transaction_hash"`
	Version         string   `json:"version"`
	MaxFeePerGas    string   `json:"max_fee_per_gas"`
	Nonce           string   `json:"nonce"`
	SenderAddress   string   `json:"sender_address"`
	Type            string   `json:"type"`
	Signatures      []string `json:"signatures"`
	Calldata        []string `json:"calldata"`
}

type TransactionReceipt

type TransactionReceipt struct {
	ExecutionStatus    string             `json:"execution_status"`
	TransactionHash    string             `json:"transaction_hash"`
	ActualFee          string             `json:"actual_fee"`
	Version            string             `json:"version"`
	L2ToL1Messages     []L2ToL1Message    `json:"l2_to_l1_messages"`
	Events             []Event            `json:"events"`
	ExecutionResources ExecutionResources `json:"execution_resources"`
	TransactionIndex   uint               `json:"transaction_index"`
}

Jump to

Keyboard shortcuts

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