Documentation ¶
Index ¶
- Constants
- func AddressFromPubKey(publicKey solana.PublicKey) string
- func GenerateNewKeypair() (*solana.PrivateKey, solana.PublicKey)
- func GetSuggestedPriorityFee(fees []PrioritizationFee) uint64
- func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)
- func PrivateKeyFromBase58(privateKeyBase58 string) (*solana.PrivateKey, error)
- func PrivateKeyFromByteList(privateKeyByteList []byte) (*solana.PrivateKey, error)
- func PrivateKeyFromHex(privateKeyHex string) (*solana.PrivateKey, error)
- func PrivateKeyHexToPrivateKey(privateKeyHex string) (*ed25519.PrivateKey, error)
- func PrivateKeyHexToPubKey(privateKeyHex string) (*ed25519.PublicKey, error)
- func PrivateKeyToBase58(privateKey *solana.PrivateKey) string
- func PrivateKeyToPubKey(privateKey *ed25519.PrivateKey) (*ed25519.PublicKey, error)
- func PubKeyHexToAddress(publicKeyHex string) (string, error)
- func PubKeyHexToPubKey(publicKeyHex string) (*ed25519.PublicKey, error)
- func PubKeyToAddress(publicKey *ed25519.PublicKey) (string, error)
- func PubKeyToPubKeyHex(publicKey *ed25519.PublicKey) (string, error)
- func PublicKeyFromBase58(publicKeyBase58 string) (solana.PublicKey, error)
- func PublicKeyFromPrivateKey(privateKey *solana.PrivateKey) solana.PublicKey
- func PublicKeyToBase58(publicKey solana.PublicKey) string
- type AccountInfo
- type AccountsInfo
- type BlockHeightResponse
- type BlockResult
- type ChainAdaptor
- func (c ChainAdaptor) BuildSignedTransaction(req *account.SignedTransactionRequest) (*account.SignedTransactionResponse, error)
- func (c *ChainAdaptor) ConvertAddress(req *account.ConvertAddressRequest) (*account.ConvertAddressResponse, error)
- func (c *ChainAdaptor) CreateUnSignTransaction(req *account.UnSignTransactionRequest) (*account.UnSignTransactionResponse, error)
- func (c *ChainAdaptor) DecodeTransaction(req *account.DecodeTransactionRequest) (*account.DecodeTransactionResponse, error)
- func (c *ChainAdaptor) GetAccount(req *account.AccountRequest) (*account.AccountResponse, error)
- func (c *ChainAdaptor) GetBlockByHash(req *account.BlockHashRequest) (*account.BlockResponse, error)
- func (c *ChainAdaptor) GetBlockByNumber(req *account.BlockNumberRequest) (*account.BlockResponse, error)
- func (c *ChainAdaptor) GetBlockByRange(req *account.BlockByRangeRequest) (*account.BlockByRangeResponse, error)
- func (c *ChainAdaptor) GetBlockHeaderByHash(req *account.BlockHeaderHashRequest) (*account.BlockHeaderResponse, error)
- func (c *ChainAdaptor) GetBlockHeaderByNumber(req *account.BlockHeaderNumberRequest) (*account.BlockHeaderResponse, error)
- func (c *ChainAdaptor) GetExtraData(req *account.ExtraDataRequest) (*account.ExtraDataResponse, error)
- func (c *ChainAdaptor) GetFee(req *account.FeeRequest) (*account.FeeResponse, error)
- func (c *ChainAdaptor) GetSupportChains(req *account.SupportChainsRequest) (*account.SupportChainsResponse, error)
- func (c *ChainAdaptor) GetTxByAddress(req *account.TxAddressRequest) (*account.TxAddressResponse, error)
- func (c *ChainAdaptor) GetTxByHash(req *account.TxHashRequest) (*account.TxHashResponse, error)
- func (c *ChainAdaptor) SendTx(req *account.SendTxRequest) (*account.SendTxResponse, error)
- func (c *ChainAdaptor) ValidAddress(req *account.ValidAddressRequest) (*account.ValidAddressResponse, error)
- func (c *ChainAdaptor) VerifySignedTransaction(req *account.VerifyTransactionRequest) (*account.VerifyTransactionResponse, error)
- type CommitmentType
- type CreateNonceAccountRequest
- type CreateNonceAccountResponse
- type GetAccountInfoResponse
- type GetBalanceResponse
- type GetBlockRequest
- type GetBlockResponse
- type GetBlocksWithLimitResponse
- type GetFeeForMessageRequest
- type GetFeeForMessageResponse
- type GetHealthResponse
- type GetLatestBlockhashResponse
- type GetSignaturesRequest
- type GetSignaturesResponse
- type GetSlotRequest
- type GetSlotResponse
- type GetTransactionResponse
- type Instruction
- type LoadedAddresses
- type PrioritizationFee
- type RPCError
- type SendTransactionRequest
- type SendTransactionResponse
- type SignatureInfo
- type SimulateRequest
- type SimulateResult
- type SimulateTransactionResponse
- type SolClient
- type SolData
- type Status
- type Transaction
- type TransactionDetail
- type TransactionDetailsType
- type TransactionHeader
- type TransactionMessage
- type TransactionMeta
- type TransactionResult
- type TransactionVersion
- type TxStructure
Constants ¶
View Source
const ( HealthOk = "ok" HealthBehind = "behind" HealthUnknown = "unknown" )
View Source
const ChainName = "Solana"
View Source
const (
MaxBlockRange = 1000
)
Variables ¶
This section is empty.
Functions ¶
func AddressFromPubKey ¶
func AddressFromPubKey(publicKey solana.PublicKey) string
func GenerateNewKeypair ¶
func GenerateNewKeypair() (*solana.PrivateKey, solana.PublicKey)
func GetSuggestedPriorityFee ¶
func GetSuggestedPriorityFee(fees []PrioritizationFee) uint64
func NewChainAdaptor ¶
func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)
func PrivateKeyFromBase58 ¶
func PrivateKeyFromByteList ¶
func PrivateKeyFromHex ¶
func PrivateKeyHexToPrivateKey ¶
func PrivateKeyHexToPrivateKey(privateKeyHex string) (*ed25519.PrivateKey, error)
func PrivateKeyHexToPubKey ¶
func PrivateKeyToBase58 ¶
func PrivateKeyToBase58(privateKey *solana.PrivateKey) string
func PrivateKeyToPubKey ¶
func PrivateKeyToPubKey(privateKey *ed25519.PrivateKey) (*ed25519.PublicKey, error)
func PubKeyHexToAddress ¶
func PublicKeyFromBase58 ¶
func PublicKeyFromPrivateKey ¶
func PublicKeyFromPrivateKey(privateKey *solana.PrivateKey) solana.PublicKey
func PublicKeyToBase58 ¶
func PublicKeyToBase58(publicKey solana.PublicKey) string
Types ¶
type AccountInfo ¶
type AccountInfo struct { // account now balance Lamports uint64 `json:"lamports"` Owner string `json:"owner"` // slice index = 0, data // slice index = 1, encode = base58, and other Data []string `json:"data"` Executable bool `json:"executable"` RentEpoch uint64 `json:"rentEpoch"` Space uint64 `json:"space"` }
type AccountsInfo ¶
type BlockHeightResponse ¶
type BlockResult ¶
type BlockResult struct { ParentSlot uint64 `json:"parentSlot"` BlockTime int64 `json:"blockTime"` BlockHeight uint64 `json:"blockHeight"` BlockHash string `json:"blockhash"` PreviousBlockhash string `json:"previousBlockhash"` Signatures []string `json:"signatures"` Transactions []TransactionDetail `json:"transactions"` }
type ChainAdaptor ¶
type ChainAdaptor struct {
// contains filtered or unexported fields
}
func (ChainAdaptor) BuildSignedTransaction ¶
func (c ChainAdaptor) BuildSignedTransaction(req *account.SignedTransactionRequest) (*account.SignedTransactionResponse, error)
func (*ChainAdaptor) ConvertAddress ¶
func (c *ChainAdaptor) ConvertAddress(req *account.ConvertAddressRequest) (*account.ConvertAddressResponse, error)
func (*ChainAdaptor) CreateUnSignTransaction ¶
func (c *ChainAdaptor) CreateUnSignTransaction(req *account.UnSignTransactionRequest) (*account.UnSignTransactionResponse, error)
func (*ChainAdaptor) DecodeTransaction ¶
func (c *ChainAdaptor) DecodeTransaction(req *account.DecodeTransactionRequest) (*account.DecodeTransactionResponse, error)
func (*ChainAdaptor) GetAccount ¶
func (c *ChainAdaptor) GetAccount(req *account.AccountRequest) (*account.AccountResponse, error)
func (*ChainAdaptor) GetBlockByHash ¶
func (c *ChainAdaptor) GetBlockByHash(req *account.BlockHashRequest) (*account.BlockResponse, error)
func (*ChainAdaptor) GetBlockByNumber ¶
func (c *ChainAdaptor) GetBlockByNumber(req *account.BlockNumberRequest) (*account.BlockResponse, error)
func (*ChainAdaptor) GetBlockByRange ¶
func (c *ChainAdaptor) GetBlockByRange(req *account.BlockByRangeRequest) (*account.BlockByRangeResponse, error)
func (*ChainAdaptor) GetBlockHeaderByHash ¶
func (c *ChainAdaptor) GetBlockHeaderByHash(req *account.BlockHeaderHashRequest) (*account.BlockHeaderResponse, error)
func (*ChainAdaptor) GetBlockHeaderByNumber ¶
func (c *ChainAdaptor) GetBlockHeaderByNumber(req *account.BlockHeaderNumberRequest) (*account.BlockHeaderResponse, error)
func (*ChainAdaptor) GetExtraData ¶
func (c *ChainAdaptor) GetExtraData(req *account.ExtraDataRequest) (*account.ExtraDataResponse, error)
func (*ChainAdaptor) GetFee ¶
func (c *ChainAdaptor) GetFee(req *account.FeeRequest) (*account.FeeResponse, error)
func (*ChainAdaptor) GetSupportChains ¶
func (c *ChainAdaptor) GetSupportChains(req *account.SupportChainsRequest) (*account.SupportChainsResponse, error)
func (*ChainAdaptor) GetTxByAddress ¶
func (c *ChainAdaptor) GetTxByAddress(req *account.TxAddressRequest) (*account.TxAddressResponse, error)
func (*ChainAdaptor) GetTxByHash ¶
func (c *ChainAdaptor) GetTxByHash(req *account.TxHashRequest) (*account.TxHashResponse, error)
func (*ChainAdaptor) SendTx ¶
func (c *ChainAdaptor) SendTx(req *account.SendTxRequest) (*account.SendTxResponse, error)
func (*ChainAdaptor) ValidAddress ¶
func (c *ChainAdaptor) ValidAddress(req *account.ValidAddressRequest) (*account.ValidAddressResponse, error)
func (*ChainAdaptor) VerifySignedTransaction ¶
func (c *ChainAdaptor) VerifySignedTransaction(req *account.VerifyTransactionRequest) (*account.VerifyTransactionResponse, error)
type CommitmentType ¶
type CommitmentType string
const ( // Finalized Confirmed Processed // Finalized wait 32 slot Finalized CommitmentType = "finalized" // Confirmed wait 2-3 slot Confirmed CommitmentType = "confirmed" // Processed wait 0 slot Processed CommitmentType = "processed" )
type CreateNonceAccountRequest ¶
type CreateNonceAccountRequest struct { // payer privateKey Payer solana.PrivateKey // nonce account Auth, PublicKey Authority solana.PublicKey }
type GetAccountInfoResponse ¶
type GetAccountInfoResponse struct { JsonRPC string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result struct { Context struct { // now slot Slot uint64 `json:"slot"` } `json:"context"` Value AccountInfo `json:"value"` } `json:"result"` }
type GetBalanceResponse ¶
type GetBlockRequest ¶
type GetBlockRequest struct { // slot status // Finalized Confirmed Processed Commitment CommitmentType `json:"commitment,omitempty"` // "json", "jsonParsed", "base58", "base64" Encoding string `json:"encoding"` // max version // Legacy = 0, no other version MaxSupportedTransactionVersion int `json:"maxSupportedTransactionVersion"` // "full", "accounts", "signatures", "none" TransactionDetails string `json:"transactionDetails"` // contain rewards Rewards bool `json:"rewards"` }
type GetBlockResponse ¶
type GetBlockResponse struct { JsonRPC string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result BlockResult `json:"result"` }
type GetBlocksWithLimitResponse ¶
type GetBlocksWithLimitResponse struct { JsonRPC string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result []uint64 `json:"result"` }
GetBlocksWithLimitResponse represents the response structure
type GetFeeForMessageRequest ¶
type GetHealthResponse ¶
type GetLatestBlockhashResponse ¶
type GetLatestBlockhashResponse struct { JsonRPC string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result struct { Context struct { Slot uint64 `json:"slot"` } `json:"context"` Value struct { Blockhash string `json:"blockhash"` LastValidBlockHeight uint64 `json:"lastValidBlockHeight"` } `json:"value"` } `json:"result"` }
type GetSignaturesRequest ¶
type GetSignaturesResponse ¶
type GetSignaturesResponse struct { Jsonrpc string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result []SignatureInfo `json:"result"` }
type GetSlotRequest ¶
type GetSlotRequest struct {
Commitment CommitmentType `json:"commitment,omitempty"`
}
type GetSlotResponse ¶
type GetTransactionResponse ¶
type GetTransactionResponse struct { Jsonrpc string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result TransactionResult `json:"result"` }
type Instruction ¶
type LoadedAddresses ¶
type PrioritizationFee ¶
type SendTransactionRequest ¶
type SendTransactionRequest struct { Encoding string `json:"encoding,omitempty"` Commitment string `json:"commitment,omitempty"` SkipPreflight bool `json:"skipPreflight,omitempty"` PreflightCommitment string `json:"preflightCommitment,omitempty"` MaxRetries uint64 `json:"maxRetries,omitempty"` MinContextSlot uint64 `json:"minContextSlot,omitempty"` }
type SendTransactionResponse ¶
type SignatureInfo ¶
type SimulateRequest ¶
type SimulateRequest struct { Commitment string `json:"commitment,omitempty"` SigVerify bool `json:"sigVerify,omitempty"` ReplaceRecentBlockhash bool `json:"replaceRecentBlockhash,omitempty"` MinContextSlot uint64 `json:"minContextSlot,omitempty"` Encoding string `json:"encoding,omitempty"` Accounts *AccountsInfo `json:"accounts,omitempty"` }
type SimulateResult ¶
type SimulateResult struct { Err interface{} `json:"err"` Logs []string `json:"logs"` UnitsConsumed uint64 `json:"unitsConsumed"` Accounts []struct { Executable bool `json:"executable"` Lamports uint64 `json:"lamports"` Owner string `json:"owner"` RentEpoch uint64 `json:"rentEpoch"` Data []string `json:"data"` } `json:"accounts,omitempty"` ReturnData *struct { ProgramId string `json:"programId"` Data []string `json:"data"` } `json:"returnData,omitempty"` InnerInstructions []struct { Index uint16 `json:"index"` Instructions []struct { ProgramIdIndex uint8 `json:"programIdIndex"` Accounts []uint8 `json:"accounts"` Data string `json:"data"` } `json:"instructions"` } `json:"innerInstructions,omitempty"` }
type SimulateTransactionResponse ¶
type SimulateTransactionResponse struct { Jsonrpc string `json:"jsonrpc"` ID int `json:"id"` Error *RPCError `json:"error,omitempty"` Result SimulateResult `json:"result"` }
type SolClient ¶
type SolClient interface { GetHealth() (string, error) GetAccountInfo(inputAddr string) (*AccountInfo, error) GetBalance(inputAddr string) (uint64, error) GetLatestBlockhash(commitmentType CommitmentType) (string, error) SendTransaction( signedTx string, config *SendTransactionRequest, ) (string, error) SimulateTransaction( signedTx string, config *SimulateRequest, ) (*SimulateResult, error) GetFeeForMessage(message string) (uint64, error) GetRecentPrioritizationFees() ([]PrioritizationFee, error) GetSlot(commitment CommitmentType) (uint64, error) GetBlocksWithLimit(startSlot uint64, limit uint64) ([]uint64, error) GetBlockBySlot(slot uint64, detailType TransactionDetailsType) (*BlockResult, error) GetTransaction(signature string) (*TransactionResult, error) GetTransactionRange(signatures []string) ([]*TransactionResult, error) GetTxForAddress( address string, commitment CommitmentType, limit uint64, beforeSignature string, untilSignature string, ) ([]SignatureInfo, error) }
func NewSolHttpClient ¶
type SolData ¶
type SolData struct {
SolDataCli *solscan.ChainExplorerAdaptor
}
func NewSolScanClient ¶
func (*SolData) GetTxByAddress ¶
func (ss *SolData) GetTxByAddress(page, pagesize uint64, address string, action account.ActionType) (*account.TransactionResponse[account.AccountTxResponse], error)
type Transaction ¶
type Transaction struct { Message TransactionMessage `json:"message"` Signatures []string `json:"signatures"` }
type TransactionDetail ¶
type TransactionDetail struct { Signature string `json:"signature"` Slot uint64 `json:"slot"` BlockTime int64 `json:"blockTime"` Meta *TransactionMeta `json:"meta"` // "version": "legacy" or "version": 0 Version any `json:"version"` Message interface{} `json:"message"` // 使用 interface{} 因为可能为 null RecentBlockhash string `json:"recentBlockhash"` }
type TransactionDetailsType ¶
type TransactionDetailsType string
const ( Full TransactionDetailsType = "full" Accounts TransactionDetailsType = "accounts" Signatures TransactionDetailsType = "signatures" None TransactionDetailsType = "none" )
type TransactionHeader ¶
type TransactionMessage ¶
type TransactionMessage struct { AccountKeys []string `json:"accountKeys"` AddressTableLookups []interface{} `json:"addressTableLookups"` Header TransactionHeader `json:"header"` Instructions []Instruction `json:"instructions"` RecentBlockhash string `json:"recentBlockhash"` }
type TransactionMeta ¶
type TransactionMeta struct { Err interface{} `json:"err"` Fee uint64 `json:"fee"` PreBalances []uint64 `json:"preBalances"` PostBalances []uint64 `json:"postBalances"` InnerInstructions []interface{} `json:"innerInstructions"` PreTokenBalances []interface{} `json:"preTokenBalances"` PostTokenBalances []interface{} `json:"postTokenBalances"` LogMessages []string `json:"logMessages"` LoadedAddresses LoadedAddresses `json:"loadedAddresses"` Status struct { Ok interface{} `json:"Ok"` } `json:"status"` Rewards interface{} `json:"rewards"` ComputeUnitsConsumed uint64 `json:"computeUnitsConsumed"` }
type TransactionResult ¶
type TransactionResult struct { Slot uint64 `json:"slot"` Version any `json:"version"` BlockTime *int64 `json:"blockTime"` Transaction Transaction `json:"transaction"` Meta TransactionMeta `json:"meta"` }
type TransactionVersion ¶
type TransactionVersion struct {
// contains filtered or unexported fields
}
type TxStructure ¶
type TxStructure struct { Nonce string `json:"nonce"` GasPrice string `json:"gas_price"` GasTipCap string `json:"gas_tip_cap"` GasFeeCap string `json:"gas_fee_cap"` Gas uint64 `json:"gas"` ContractAddress string `json:"contract_address"` FromAddress string `json:"from_address"` ToAddress string `json:"to_address"` TokenId string `json:"token_id"` Value string `json:"value"` FromPrivateKey string `json:"from_privatekey"` }
Click to show internal directories.
Click to hide internal directories.