Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidAddress = errors.New("invalid blockchain address format") ErrInvalidChain = errors.New("unsupported or invalid blockchain network") ErrInsufficientGas = errors.New("insufficient funds for gas") ErrTxFailed = errors.New("transaction failed on chain") )
Common errors in the Web3 domain.
Functions ¶
func NormalizeAddress ¶
NormalizeAddress ensures addresses are stored in a consistent format (lowercase for EVM).
Types ¶
type Balance ¶
type Balance struct {
WalletAddress string `json:"wallet_address"`
ContractAddress string `json:"contract_address,omitempty"` // Empty for native currency
Chain Chain `json:"chain"`
Amount string `json:"amount"` // Raw amount (Wei/Lamports)
Decimals int `json:"decimals"`
Symbol string `json:"symbol"`
UpdatedAt time.Time `json:"updated_at"`
}
Balance represents a snapshot of an asset holding.
type Collection ¶
type Collection struct {
ContractAddress string `json:"contract_address"`
Chain Chain `json:"chain"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Standard TokenType `json:"standard"`
Verified bool `json:"verified"`
}
Collection represents a grouping of NFTs (Smart Contract).
type MainnetChain ¶
type MainnetChain Chain
const ( ChainEthereum MainnetChain = "ethereum" ChainPolygon MainnetChain = "polygon" ChainBSC MainnetChain = "bsc" ChainSolana MainnetChain = "solana" ChainArbitrum MainnetChain = "arbitrum" ChainOptimism MainnetChain = "optimism" )
type NFT ¶
type NFT struct {
ID string `json:"id"`
ContractAddress string `json:"contract_address"`
TokenID string `json:"token_id"` // String to handle large big.Int values
Chain Chain `json:"chain"`
Standard TokenType `json:"standard"`
OwnerAddress string `json:"owner_address"`
Name string `json:"name"`
Description string `json:"description"`
ImageURL string `json:"image_url"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
MintedAt *time.Time `json:"minted_at,omitempty"`
LastSyncedAt time.Time `json:"last_synced_at"`
}
NFT represents a Non-Fungible Token asset.
type Transaction ¶
type Transaction struct {
ID string `json:"id"`
Hash string `json:"hash"`
Chain Chain `json:"chain"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
Value string `json:"value"` // Amount in Wei/Lamports as string
GasPrice string `json:"gas_price,omitempty"`
GasUsed uint64 `json:"gas_used,omitempty"`
Nonce uint64 `json:"nonce"`
BlockNumber uint64 `json:"block_number,omitempty"`
BlockHash string `json:"block_hash,omitempty"`
Status TransactionStatus `json:"status"`
InputData string `json:"input_data,omitempty"` // Hex encoded input data
Confirmations uint64 `json:"confirmations"`
Timestamp time.Time `json:"timestamp"`
}
Transaction represents a state change on the blockchain.
func (*Transaction) ExplorerURL ¶
func (tx *Transaction) ExplorerURL() string
ExplorerURL returns the public block explorer URL for this transaction.
func (*Transaction) IsConfirmed ¶
func (tx *Transaction) IsConfirmed() bool
IsConfirmed checks if the transaction is considered final based on status.
type TransactionStatus ¶
type TransactionStatus string
TransactionStatus represents the lifecycle state of a blockchain transaction.
const ( TxStatusPending TransactionStatus = "PENDING" TxStatusConfirmed TransactionStatus = "CONFIRMED" TxStatusFailed TransactionStatus = "FAILED" TxStatusDropped TransactionStatus = "DROPPED" )
type Wallet ¶
type Wallet struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Address string `json:"address"`
Chain Chain `json:"chain"`
Label string `json:"label,omitempty"`
IsCustodial bool `json:"is_custodial"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Wallet represents a user's cryptographic wallet on a specific chain.