Documentation ¶
Index ¶
- Constants
- Variables
- func BigToHex(in *big.Int) string
- func BytesToBig(bytes []byte) *big.Int
- func ComputeFact(programHash *big.Int, programOutputs []*big.Int) *big.Int
- func FmtKecBytes(in *big.Int, rolen int) (buf []byte)
- func GetSelectorFromName(funcName string) *big.Int
- func HexToBN(hexString string) *big.Int
- func HexToBytes(hexString string) ([]byte, error)
- func HexToShortStr(hexStr string) string
- func Keccak256(data ...[]byte) []byte
- func MaskBits(mask, wordSize int, slice []byte) (ret []byte)
- func SNValToBN(str string) *big.Int
- func SplitFactStr(fact string) (fact_low, fact_high string)
- func StrToBig(str string) *big.Int
- func UTF8StrToBig(str string) *big.Int
- type ABI
- type ABIEntry
- type ABIType
- type AddDeclareResponse
- type AddDeployResponse
- type AddInvokeTransactionOutput
- type ContractClass
- type DeployAccountRequest
- type DeployRequest
- type EntryPoint
- type EntryPointsByType
- type EventABIEntry
- type ExecuteDetails
- type FeeEstimate
- type Felt
- func (f *Felt) Big() *big.Int
- func (f Felt) MarshalGQL(w io.Writer)
- func (f Felt) MarshalJSON() ([]byte, error)
- func (f *Felt) Scan(src interface{}) error
- func (f *Felt) ShortString() string
- func (f *Felt) String() string
- func (b *Felt) UnmarshalGQL(v interface{}) error
- func (f *Felt) UnmarshalJSON(p []byte) error
- func (f Felt) Value() (driver.Value, error)
- type FunctionABIEntry
- type FunctionCall
- type FunctionInvoke
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value
- func (h Hash) Hex() string
- func (Hash) ImplementsGraphQLType(name string) bool
- func (h Hash) MarshalJSON() ([]byte, error)
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) Scan(src interface{}) error
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalGraphQL(input interface{}) error
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- func (h Hash) Value() (driver.Value, error)
- type KeccakState
- type Member
- type NumAsHex
- type Signature
- type StructABIEntry
- type TransactionState
- type TypedParameter
- type Uint256
Constants ¶
const ( FIELD_GEN int = 3 FIELD_PRIME string = "3618502788666131213697322783095070105623107215331596699973092056135872020481" )
const HashLength = 32
HashLength is the expected length of the hash
Variables ¶
var (
MaxFelt = StrToFelt(FIELD_PRIME)
)
Functions ¶
func BytesToBig ¶
func ComputeFact ¶
compute the keccack fact given the program hash and outputs
func FmtKecBytes ¶
format the bytes in Keccak hash
func GetSelectorFromName ¶
func HexToBytes ¶
trim "0x" prefix(if exists) and converts hexidecimal string to byte slice
func HexToShortStr ¶
convert hex string to StarkNet 'short string'
func Keccak256 ¶
Keccak256 calculates and returns the Keccak256 hash of the input data. (ref: https://github.com/ethereum/go-ethereum/blob/master/crypto/crypto.go)
func SplitFactStr ¶
split a fact into two felts
Types ¶
type AddDeclareResponse ¶
type AddDeployResponse ¶
type AddInvokeTransactionOutput ¶
type AddInvokeTransactionOutput struct {
TransactionHash string `json:"transaction_hash"`
}
type ContractClass ¶
type ContractClass struct { // Program A base64 representation of the compressed program code Program string `json:"program"` EntryPointsByType EntryPointsByType `json:"entry_points_by_type"` ABI *ABI `json:"abi,omitempty"` }
func (*ContractClass) UnmarshalJSON ¶
func (c *ContractClass) UnmarshalJSON(content []byte) error
type DeployAccountRequest ¶
type DeployAccountRequest struct { MaxFee *big.Int `json:"max_fee"` // Version of the transaction scheme, should be set to 0 or 1 Version *big.Int `json:"version"` // Signature Signature Signature `json:"signature"` // Nonce should only be set with Transaction V1 Nonce *big.Int `json:"nonce,omitempty"` Type string `json:"type"` ContractAddressSalt string `json:"contract_address_salt"` ConstructorCalldata []string `json:"constructor_calldata"` ClassHash string `json:"class_hash"` }
type DeployRequest ¶
type DeployRequest struct { Type string `json:"type"` ContractAddressSalt string `json:"contract_address_salt"` ConstructorCalldata []string `json:"constructor_calldata"` ContractDefinition ContractClass `json:"contract_definition"` }
type EntryPoint ¶
type EntryPointsByType ¶
type EntryPointsByType struct { Constructor []EntryPoint `json:"CONSTRUCTOR"` External []EntryPoint `json:"EXTERNAL"` L1Handler []EntryPoint `json:"L1_HANDLER"` }
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
type ExecuteDetails ¶
ExecuteDetails provides some details about the execution.
type FeeEstimate ¶
type FeeEstimate struct { // GasConsumed the Ethereum gas cost of the transaction (see https://docs.starknet.io/docs/Fees/fee-mechanism for more info) GasConsumed NumAsHex `json:"gas_consumed"` // GasPrice the gas price (in gwei) that was used in the cost estimation GasPrice NumAsHex `json:"gas_price"` // OverallFee the estimated fee for the transaction (in gwei), product of gas_consumed and gas_price OverallFee NumAsHex `json:"overall_fee"` }
type Felt ¶
Felt represents Field Element or Felt from cairo.
func BytesToFelt ¶
BytesToFelt converts a []byte to its Felt representation.
func StrToFelt ¶
StrToFelt converts a string containing a decimal, hexadecimal or UTF8 charset into a Felt.
func (Felt) MarshalGQL ¶
MarshalGQL implements the gqlgen Marshaller interface to marshal Felt into an io.Writer.
func (Felt) MarshalJSON ¶
MarshalJSON implements the json Marshaller interface for Felt to marshal types to []byte.
func (*Felt) Scan ¶
Scan implements the database/sql Scanner interface to read Felt from a databases.
func (*Felt) ShortString ¶
String converts a Felt into its 'short string' representation.
func (*Felt) String ¶
String converts a Felt into its hexadecimal string representation and implement fmt.Stringer.
func (*Felt) UnmarshalGQL ¶
UnmarshalGQL implements the gqlgen Unmarshaller interface to unmarshal an interface into a Felt.
func (*Felt) UnmarshalJSON ¶
UnmarshalJSON implements the json Unmarshaller interface to unmarshal []byte into types.
type FunctionABIEntry ¶
type FunctionABIEntry struct { // The function type Type ABIType `json:"type"` // The function name Name string `json:"name"` StateMutability *string `json:"stateMutability,omitempty"` Inputs []TypedParameter `json:"inputs"` Outputs []TypedParameter `json:"outputs"` }
func (*FunctionABIEntry) IsType ¶
func (f *FunctionABIEntry) IsType() ABIType
type FunctionCall ¶
type FunctionCall struct { ContractAddress Hash `json:"contract_address"` EntryPointSelector string `json:"entry_point_selector,omitempty"` // Calldata The parameters passed to the function Calldata []string `json:"calldata"` }
FunctionCall function call information
type FunctionInvoke ¶
type FunctionInvoke struct { MaxFee *big.Int `json:"max_fee"` // Version of the transaction scheme, should be set to 0 or 1 Version *big.Int `json:"version"` // Signature Signature Signature `json:"signature"` // Nonce should only be set with Transaction V1 Nonce *big.Int `json:"nonce,omitempty"` // Defines the transaction type to invoke Type string `json:"type,omitempty"` FunctionCall }
type Hash ¶
type Hash [HashLength]byte
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %q, %x, %X and %d format verbs.
func (Hash) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
func (Hash) MarshalJSON ¶
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type KeccakState ¶
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.
func NewKeccakState ¶
func NewKeccakState() KeccakState
NewKeccakState creates a new KeccakState (ref: https://github.com/ethereum/go-ethereum/blob/master/crypto/crypto.go)
type Member ¶
type Member struct { TypedParameter Offset uint64 `json:"offset"` }
type Signature ¶
func (Signature) MarshalJSON ¶
MarshalJSON implements the json Marshaller interface for a Signature array to marshal types to []byte.
type StructABIEntry ¶
type StructABIEntry struct { // The event type Type ABIType `json:"type"` // The event name Name string `json:"name"` Size uint64 `json:"size"` Members []Member `json:"members"` }
func (*StructABIEntry) IsType ¶
func (s *StructABIEntry) IsType() ABIType
type TransactionState ¶
type TransactionState string
const ( TransactionAcceptedOnL1 TransactionState = "ACCEPTED_ON_L1" TransactionAcceptedOnL2 TransactionState = "ACCEPTED_ON_L2" TransactionNotReceived TransactionState = "NOT_RECEIVED" TransactionPending TransactionState = "PENDING" TransactionReceived TransactionState = "RECEIVED" TransactionRejected TransactionState = "REJECTED" )
func (TransactionState) IsTransactionFinal ¶
func (s TransactionState) IsTransactionFinal() bool
func (TransactionState) MarshalJSON ¶
func (ts TransactionState) MarshalJSON() ([]byte, error)
func (TransactionState) String ¶
func (s TransactionState) String() string
func (*TransactionState) UnmarshalJSON ¶
func (ts *TransactionState) UnmarshalJSON(data []byte) error