Documentation
¶
Overview ¶
Package crosschain is a Go library to interact with multiple blockchains.
Crosschain main design principle is to isolate network Client, Signer and tx Builder. This way you can build applications or micro services using just what you need and with the convenience of a unified interface.
Index ¶
- Constants
- Variables
- func CheckFeeLimit(input TxInput, chainConfig *ChainConfig) error
- func IsTypeOf(input TxInput, validTypes ...any) bool
- type AdditionalNativeAsset
- type Address
- type AddressBuilder
- type AddressBuilderWithFormats
- type AddressConfig
- type AddressFormat
- type AmountBlockchain
- func MultiplyByFloat(amount AmountBlockchain, multiplier float64) AmountBlockchain
- func NewAmountBlockchainFromInt64(i64 int64) (AmountBlockchain, bool)
- func NewAmountBlockchainFromStr(str string) AmountBlockchain
- func NewAmountBlockchainFromUint64(u64 uint64) AmountBlockchain
- func NewAmountBlockchainToMaskFloat64(f64 float64) AmountBlockchain
- func (amount *AmountBlockchain) Abs() AmountBlockchain
- func (amount *AmountBlockchain) Add(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) ApplyGasPriceMultiplier(chain *ChainClientConfig) AmountBlockchain
- func (amount AmountBlockchain) ApplySecondaryGasPriceMultiplier(chain *ChainClientConfig) AmountBlockchain
- func (amount AmountBlockchain) Bytes() []byte
- func (amount *AmountBlockchain) Cmp(other *AmountBlockchain) int
- func (amount *AmountBlockchain) Div(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) Int() *big.Int
- func (amount *AmountBlockchain) IsZero() bool
- func (b AmountBlockchain) MarshalJSON() ([]byte, error)
- func (amount *AmountBlockchain) Mul(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) Sign() int
- func (amount AmountBlockchain) String() string
- func (amount *AmountBlockchain) Sub(x *AmountBlockchain) AmountBlockchain
- func (amount *AmountBlockchain) ToHuman(decimals int32) AmountHumanReadable
- func (amount AmountBlockchain) Uint64() uint64
- func (b *AmountBlockchain) UnmarshalJSON(p []byte) error
- func (amount AmountBlockchain) UnmaskFloat64() float64
- type AmountHumanReadable
- func (amount AmountHumanReadable) Cmp(x AmountHumanReadable) int
- func (amount AmountHumanReadable) Decimal() decimal.Decimal
- func (amount AmountHumanReadable) Div(x AmountHumanReadable) AmountHumanReadable
- func (b AmountHumanReadable) IsZero() bool
- func (b AmountHumanReadable) MarshalJSON() ([]byte, error)
- func (b AmountHumanReadable) MarshalYAML() (interface{}, error)
- func (amount AmountHumanReadable) Mul(x AmountHumanReadable) AmountHumanReadable
- func (amount AmountHumanReadable) String() string
- func (amount AmountHumanReadable) ToBlockchain(decimals int32) AmountBlockchain
- func (b *AmountHumanReadable) UnmarshalJSON(p []byte) error
- func (b *AmountHumanReadable) UnmarshalYAML(node *yaml.Node) error
- type CallTxInput
- type ChainBaseConfig
- type ChainClientConfig
- type ChainConfig
- func (chain *ChainConfig) Base() *ChainBaseConfig
- func (chain *ChainConfig) Client() *ChainClientConfig
- func (native *ChainConfig) ClientURL() (string, Driver)
- func (chain *ChainConfig) Configure(httpTimeout time.Duration)
- func (chain *ChainConfig) DefaultHttpClient() *http.Client
- func (native *ChainConfig) FindAdditionalNativeAsset(contract ContractAddress) (*AdditionalNativeAsset, bool)
- func (native *ChainConfig) GetAssetSymbol() string
- func (asset *ChainConfig) GetChain() *ChainConfig
- func (native *ChainConfig) GetContract() string
- func (asset *ChainConfig) GetDecimals() int32
- func (native *ChainConfig) IsChain(contract ContractAddress) bool
- func (c ChainConfig) String() string
- func (chain *ChainConfig) WithAuth(auth config.Secret) *ChainConfig
- func (chain *ChainConfig) WithChainCoin(chainCoin string) *ChainConfig
- func (chain *ChainConfig) WithChainID(chainID string) *ChainConfig
- func (chain *ChainConfig) WithChainPrefix(chainPrefix string) *ChainConfig
- func (chain *ChainConfig) WithDecimals(decimals int32) *ChainConfig
- func (chain *ChainConfig) WithDriver(driver Driver) *ChainConfig
- func (chain *ChainConfig) WithFeeLimit(feeLimit AmountHumanReadable) *ChainConfig
- func (chain *ChainConfig) WithGasBudgetDefault(gasBudgetDefault AmountHumanReadable) *ChainConfig
- func (chain *ChainConfig) WithGasPriceMultiplier(multiplier float64) *ChainConfig
- func (chain *ChainConfig) WithHttpTimeout(httpTimeout time.Duration) *ChainConfig
- func (chain *ChainConfig) WithIndexer(indexerType string, url string) *ChainConfig
- func (chain *ChainConfig) WithMaxGasPrice(maxGasPrice float64) *ChainConfig
- func (chain *ChainConfig) WithMinGasPrice(minGasPrice float64) *ChainConfig
- func (chain *ChainConfig) WithNet(net string) *ChainConfig
- func (chain *ChainConfig) WithProvider(provider string) *ChainConfig
- func (chain *ChainConfig) WithTransactionActiveTime(transactionActiveTime time.Duration) *ChainConfig
- func (chain *ChainConfig) WithUrl(url string) *ChainConfig
- type ClientConfig
- type ConfirmationsConfig
- type ContractAddress
- type CrosschainClientConfig
- type Driver
- type ExplorerUrls
- type External
- type GasFeePriority
- type ITask
- type MultiTransferInput
- type NativeAsset
- type NetworkSelector
- type PublicKeyFormat
- type SignatureRequest
- type SignatureResponse
- type SignatureType
- type StakeTxInput
- type StakingConfig
- type StakingProvider
- type StringOrInt
- type Tx
- type TxAdditionalSighashes
- type TxCall
- type TxHash
- type TxInput
- type TxInputConflicts
- type TxInputEnvelope
- type TxInputGasFeeMultiplier
- type TxInputGetMaxPossibleFee
- type TxInputWithUnix
- type TxLegacyGetSignatures
- type TxSignature
- type TxStatus
- type TxVariantInput
- type TxVariantInputType
- func NewCallingInputType(driver Driver) TxVariantInputType
- func NewMultiTransferInputType(driver Driver, variant string) TxVariantInputType
- func NewStakingInputType(driver Driver, variant string) TxVariantInputType
- func NewUnstakingInputType(driver Driver, variant string) TxVariantInputType
- func NewWithdrawingInputType(driver Driver, variant string) TxVariantInputType
- type TxWithMetadata
- type UnstakeTxInput
- type WithdrawTxInput
Constants ¶
const ( K256Keccak = SignatureType("k256-keccak") K256Sha256 = SignatureType("k256-sha256") Ed255 = SignatureType("ed255") Schnorr = SignatureType("schnorr") Bls12_381G2Blake2 = SignatureType("bls12-381-g2-blake2") )
const ( ACA = NativeAsset("ACA") // Acala ADA = NativeAsset("ADA") // Cardano AKT = NativeAsset("AKT") // Akash APTOS = NativeAsset("APTOS") // APTOS ArbETH = NativeAsset("ArbETH") // Arbitrum ASTR = NativeAsset("ASTR") // Astar ATOM = NativeAsset("ATOM") // Cosmos AurETH = NativeAsset("AurETH") // Aurora AVAX = NativeAsset("AVAX") // Avalanche BAND = NativeAsset("BAND") // Band BASE = NativeAsset("BASE") // BASE BABY = NativeAsset("BABY") // Babylon BERA = NativeAsset("BERA") // Berachain BCH = NativeAsset("BCH") // Bitcoin Cash BNB = NativeAsset("BNB") // Binance Coin BTC = NativeAsset("BTC") // Bitcoin CELO = NativeAsset("CELO") // Celo CHZ = NativeAsset("CHZ") // Chiliz CHZ2 = NativeAsset("CHZ2") // Chiliz 2.0 DASH = NativeAsset("DASH") // Dash DOGE = NativeAsset("DOGE") // Dogecoin DOT = NativeAsset("DOT") // Polkadot DUSK = NativeAsset("DUSK") // Dusk ENJ = NativeAsset("ENJ") // Enjin EOS = NativeAsset("EOS") // EOS ES = NativeAsset("ES") // Eclipse ETC = NativeAsset("ETC") // Ethereum Classic ETH = NativeAsset("ETH") // Ethereum ETHW = NativeAsset("ETHW") // Ethereum PoW FIL = NativeAsset("FIL") // Filecoin FLUX = NativeAsset("FLUX") // Flux FOGO = NativeAsset("FOGO") // Fogo FTM = NativeAsset("FTM") // Fantom FRAX = NativeAsset("FRAX") // Frax GUSDT = NativeAsset("GUSDT") // Stable HASH = NativeAsset("HASH") // Provenance HBAR = NativeAsset("HBAR") // Hedera HyperEVM = NativeAsset("HyperEVM") // HyperEVM (Hyperliquid) HYPE = NativeAsset("HYPE") // Hyperliquid INJ = NativeAsset("INJ") // Injective LinETH = NativeAsset("LinETH") // Linea LTC = NativeAsset("LTC") // Litecoin LUNA = NativeAsset("LUNA") // Terra V2 LUNC = NativeAsset("LUNC") // Terra Classic KAR = NativeAsset("KAR") // Karura KAS = NativeAsset("KAS") // Kaspa KAVA = NativeAsset("KAVA") // Kava KLAY = NativeAsset("KLAY") // Klaytn KSM = NativeAsset("KSM") // Kusama MATIC = NativeAsset("MATIC") // Polygon MON = NativeAsset("MON") // MONAD NEAR = NativeAsset("NEAR") // Near NOBLE = NativeAsset("NOBLE") // Noble Chain OAS = NativeAsset("OAS") // Oasys (not Oasis!) OptETH = NativeAsset("OptETH") // Optimism EmROSE = NativeAsset("EmROSE") // Rose (Oasis EVM-compat "Emerald" parachain) SOL = NativeAsset("SOL") // Solana SUI = NativeAsset("SUI") // SUI XPLA = NativeAsset("XPLA") // XPLA TAO = NativeAsset("TAO") // Bittensor TEMPO = NativeAsset("TEMPO") // Tempo TIA = NativeAsset("TIA") // celestia TON = NativeAsset("TON") // TON TRX = NativeAsset("TRX") // TRON SEI = NativeAsset("SEI") // Sei SeiEVM = NativeAsset("SeiEVM") // SeiEVM XDC = NativeAsset("XDC") // XinFin XPL = NativeAsset("XPL") // Plasma XRP = NativeAsset("XRP") // XRP XLM = NativeAsset("XLM") // XLM ZETA = NativeAsset("ZETA") // ZetaChain NIL = NativeAsset("NIL") // Nillion ICP = NativeAsset("ICP") // Internet Computer Protocol ZEC = NativeAsset("ZEC") // Zcash ZeroG = NativeAsset("0G") // 0g )
List of supported NativeAsset
const ( DriverAptos = Driver("aptos") DriverBitcoin = Driver("bitcoin") DriverBitcoinCash = Driver("bitcoin-cash") DriverBitcoinLegacy = Driver("bitcoin-legacy") DriverCardano = Driver("cardano") DriverCosmos = Driver("cosmos") DriverCosmosEvmos = Driver("evmos") DriverDusk = Driver("dusk") DriverEOS = Driver("eos") DriverEVM = Driver("evm") DriverEVMLegacy = Driver("evm-legacy") DriverFilecoin = Driver("filecoin") DriverHedera = Driver("hedera") DriverHyperliquid = Driver("hyperliquid") DriverInternetComputerProtocol = Driver("icp") DriverKaspa = Driver("kaspa") DriverNear = Driver("near") DriverSubstrate = Driver("substrate") DriverSolana = Driver("solana") DriverSui = Driver("sui") DriverTron = Driver("tron") DriverTon = Driver("ton") DriverXrp = Driver("xrp") DriverXlm = Driver("xlm") DriverZcash = Driver("zcash") // Crosschain is a client-only driver DriverCrosschain = Driver("crosschain") )
List of supported Driver
const FLOAT_PRECISION = 6
Variables ¶
var NativeAssetList []NativeAsset = []NativeAsset{ ADA, AKT, BAND, BABY, BCH, BTC, DASH, DOGE, LTC, ACA, APTOS, ArbETH, ASTR, ATOM, AurETH, AVAX, BERA, BNB, CELO, CHZ, CHZ2, DOT, DUSK, ENJ, EOS, ES, ETC, ETH, ETHW, FIL, FLUX, FOGO, FTM, FRAX, GUSDT, HBAR, HyperEVM, INJ, LinETH, HASH, HYPE, LUNA, LUNC, KAR, KAS, KAVA, KLAY, KSM, XDC, MATIC, MON, NEAR, OAS, OptETH, EmROSE, SOL, SUI, XPLA, TAO, TIA, TON, TRX, SEI, SeiEVM, XRP, BASE, NOBLE, XPL, XLM, ZETA, NIL, ICP, ZEC, ZeroG, }
var SupportedDrivers = []Driver{ DriverAptos, DriverBitcoin, DriverBitcoinCash, DriverBitcoinLegacy, DriverCosmos, DriverCosmosEvmos, DriverEOS, DriverEVM, DriverEVMLegacy, DriverFilecoin, DriverHedera, DriverInternetComputerProtocol, DriverKaspa, DriverNear, DriverSubstrate, DriverSolana, DriverSui, DriverTron, DriverTon, DriverXrp, DriverXlm, DriverZcash, }
var SupportedStakingProviders = []StakingProvider{ Native, Kiln, Figment, Twinstake, }
Functions ¶
func CheckFeeLimit ¶
func CheckFeeLimit(input TxInput, chainConfig *ChainConfig) error
Check against the max-fee defaults in the configuration. Custody products should have a way to override max-fee limits.
Types ¶
type AdditionalNativeAsset ¶
type AdditionalNativeAsset struct {
// The asset ID of the asset to use
AssetId string `yaml:"asset_id,omitempty"`
// The native asset that this bridged asset corresponds to or settles in (e.g., "chains/ETH/assets/ETH" for OptEth or Eclipse)
BridgedAsset string `yaml:"bridged_asset,omitempty"`
// The on-chain contract ID of the asset
ContractId ContractAddress `yaml:"contract_id,omitempty"`
// Decimals for the asset
Decimals int32 `yaml:"decimals,omitempty"`
// Maximum fee limit
FeeLimit AmountHumanReadable `yaml:"fee_limit"`
Aliases []string `yaml:"aliases,omitempty"`
}
func NewAdditionalNativeAsset ¶
func NewAdditionalNativeAsset(assetId, bridgedAsset string, contractId ContractAddress, decimals int32, feeLimit AmountHumanReadable, aliases ...string) *AdditionalNativeAsset
func (*AdditionalNativeAsset) HasAlias ¶
func (na *AdditionalNativeAsset) HasAlias(alias string) bool
type Address ¶
type Address string
Address is an address on the blockchain, either sender or recipient
type AddressBuilder ¶
AddressBuilder is the interface for building addresses
type AddressBuilderWithFormats ¶
type AddressBuilderWithFormats interface {
// Returns the signature algorithm to be used for a given address format
GetSignatureAlgorithm() SignatureType
}
type AddressConfig ¶
type AddressConfig struct {
// All formats supported by chain, including default
Formats []AddressFormat `yaml:"formats,omitempty"`
}
Optional address configuration
type AddressFormat ¶
type AddressFormat string
Address format is a format of an addres, in case the chain support multiple formats
type AmountBlockchain ¶
AmountBlockchain is a big integer amount as blockchain expects it for tx.
func MultiplyByFloat ¶
func MultiplyByFloat(amount AmountBlockchain, multiplier float64) AmountBlockchain
func NewAmountBlockchainFromInt64 ¶
func NewAmountBlockchainFromInt64(i64 int64) (AmountBlockchain, bool)
NewAmountBlockchainFromUint64 creates a new AmountBlockchain from a uint64
func NewAmountBlockchainFromStr ¶
func NewAmountBlockchainFromStr(str string) AmountBlockchain
NewAmountBlockchainFromStr creates a new AmountBlockchain from a string
func NewAmountBlockchainFromUint64 ¶
func NewAmountBlockchainFromUint64(u64 uint64) AmountBlockchain
NewAmountBlockchainFromUint64 creates a new AmountBlockchain from a uint64
func NewAmountBlockchainToMaskFloat64 ¶
func NewAmountBlockchainToMaskFloat64(f64 float64) AmountBlockchain
NewAmountBlockchainToMaskFloat64 creates a new AmountBlockchain as a float64 times 10^FLOAT_PRECISION
func (*AmountBlockchain) Abs ¶
func (amount *AmountBlockchain) Abs() AmountBlockchain
func (*AmountBlockchain) Add ¶
func (amount *AmountBlockchain) Add(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Add()
func (AmountBlockchain) ApplyGasPriceMultiplier ¶
func (amount AmountBlockchain) ApplyGasPriceMultiplier(chain *ChainClientConfig) AmountBlockchain
func (AmountBlockchain) ApplySecondaryGasPriceMultiplier ¶
func (amount AmountBlockchain) ApplySecondaryGasPriceMultiplier(chain *ChainClientConfig) AmountBlockchain
func (AmountBlockchain) Bytes ¶
func (amount AmountBlockchain) Bytes() []byte
func (*AmountBlockchain) Cmp ¶
func (amount *AmountBlockchain) Cmp(other *AmountBlockchain) int
Use the underlying big.Int.Cmp()
func (*AmountBlockchain) Div ¶
func (amount *AmountBlockchain) Div(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Div()
func (AmountBlockchain) Int ¶
func (amount AmountBlockchain) Int() *big.Int
Int converts an AmountBlockchain into *bit.Int
func (*AmountBlockchain) IsZero ¶
func (amount *AmountBlockchain) IsZero() bool
func (AmountBlockchain) MarshalJSON ¶
func (b AmountBlockchain) MarshalJSON() ([]byte, error)
func (*AmountBlockchain) Mul ¶
func (amount *AmountBlockchain) Mul(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Mul()
func (AmountBlockchain) Sign ¶
func (amount AmountBlockchain) Sign() int
func (AmountBlockchain) String ¶
func (amount AmountBlockchain) String() string
func (*AmountBlockchain) Sub ¶
func (amount *AmountBlockchain) Sub(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Sub()
func (*AmountBlockchain) ToHuman ¶
func (amount *AmountBlockchain) ToHuman(decimals int32) AmountHumanReadable
func (AmountBlockchain) Uint64 ¶
func (amount AmountBlockchain) Uint64() uint64
Uint64 converts an AmountBlockchain into uint64
func (*AmountBlockchain) UnmarshalJSON ¶
func (b *AmountBlockchain) UnmarshalJSON(p []byte) error
func (AmountBlockchain) UnmaskFloat64 ¶
func (amount AmountBlockchain) UnmaskFloat64() float64
UnmaskFloat64 converts an AmountBlockchain into float64 given the number of decimals
type AmountHumanReadable ¶
AmountHumanReadable is a decimal amount as a human expects it for readability.
func NewAmountHumanReadableFromBlockchain ¶
func NewAmountHumanReadableFromBlockchain(amt AmountBlockchain) AmountHumanReadable
NewAmountHumanReadableFromBlockchain creates a new AmountHumanReadable from an AmountBlockchain
func NewAmountHumanReadableFromFloat ¶
func NewAmountHumanReadableFromFloat(float float64) AmountHumanReadable
NewAmountHumanReadableFromFloat creates a new AmountHumanReadable from a float
func NewAmountHumanReadableFromStr ¶
func NewAmountHumanReadableFromStr(str string) (AmountHumanReadable, error)
NewAmountHumanReadableFromStr creates a new AmountHumanReadable from a string
func (AmountHumanReadable) Cmp ¶
func (amount AmountHumanReadable) Cmp(x AmountHumanReadable) int
func (AmountHumanReadable) Decimal ¶
func (amount AmountHumanReadable) Decimal() decimal.Decimal
func (AmountHumanReadable) Div ¶
func (amount AmountHumanReadable) Div(x AmountHumanReadable) AmountHumanReadable
func (AmountHumanReadable) IsZero ¶
func (b AmountHumanReadable) IsZero() bool
func (AmountHumanReadable) MarshalJSON ¶
func (b AmountHumanReadable) MarshalJSON() ([]byte, error)
func (AmountHumanReadable) MarshalYAML ¶
func (b AmountHumanReadable) MarshalYAML() (interface{}, error)
func (AmountHumanReadable) Mul ¶
func (amount AmountHumanReadable) Mul(x AmountHumanReadable) AmountHumanReadable
func (AmountHumanReadable) String ¶
func (amount AmountHumanReadable) String() string
func (AmountHumanReadable) ToBlockchain ¶
func (amount AmountHumanReadable) ToBlockchain(decimals int32) AmountBlockchain
func (*AmountHumanReadable) UnmarshalJSON ¶
func (b *AmountHumanReadable) UnmarshalJSON(p []byte) error
func (*AmountHumanReadable) UnmarshalYAML ¶
func (b *AmountHumanReadable) UnmarshalYAML(node *yaml.Node) error
type CallTxInput ¶
type CallTxInput interface {
TxVariantInput
Calling()
}
type ChainBaseConfig ¶
type ChainBaseConfig struct {
// The crosschain symbol of the chain
Chain NativeAsset `yaml:"chain,omitempty"`
// The driver to use for the chain
Driver Driver `yaml:"driver,omitempty"`
// The network selector, if necessary (e.g. select mainnet, testnet, or devnet for bitcoin chains)
Network string `yaml:"net,omitempty"`
// Decimals for the chain's native asset (if it has one).
Decimals int32 `yaml:"decimals,omitempty"`
// The ChainID of the chain, either in integer or string format
ChainID StringOrInt `yaml:"chain_id,omitempty"`
// Human readable name of the chain, e.g. "Bitcoin"
ChainName string `yaml:"chain_name,omitempty"`
// Does the chain use a special prefix for it's address?
// E.g. most cosmos chains do this.
ChainPrefix StringOrInt `yaml:"chain_prefix,omitempty"`
// If the chain has a native asset, and it has an actual contract address, it should be set here.
// This is also referred to as the "ContractID".
// E.g.
// - APTOS has 0x1::aptos_coin::AptosCoin
// - INJ has inj
// - HASH has nhash
// - LUNA has uluna
ChainCoin string `yaml:"chain_coin,omitempty"`
// Additional native assets that may be used to pay fees on the chain.
NativeAssets []*AdditionalNativeAsset `yaml:"native_assets,omitempty"`
// If true, then the `.Chain` does not represent any native asset (i.e. no chain-coin, no decimals).
NoNativeAsset bool `yaml:"no_native_asset,omitempty"`
// If necessary, specific which asset to use to spend for gas.
GasCoin string `yaml:"gas_coin,omitempty"`
// Indicate if this chain should not be included.
Disabled *bool `yaml:"disabled,omitempty"`
// Staking configuration
Staking StakingConfig `yaml:"staking,omitempty"`
// Maximum total fee limit: required for caller to make use of with `TxInput.GetFeeLimit()`
FeeLimit AmountHumanReadable `yaml:"fee_limit,omitempty"`
// Transfer tax is percentage that the network takes from every transfer .. only used so far for Terra Classic
ChainTransferTax float64 `yaml:"chain_transfer_tax,omitempty"`
// Used only for deriving private keys from mnemonic phrases in local testing
ChainCoinHDPath uint32 `yaml:"chain_coin_hd_path,omitempty"`
// Should use `ChainID` instead
XChainIDStr string `yaml:"chain_id_str,omitempty"`
// Optional address configuration
Address AddressConfig `yaml:"address,omitempty"`
}
type ChainClientConfig ¶
type ChainClientConfig struct {
URL string `yaml:"url,omitempty"`
SecondaryURL string `yaml:"secondary_url,omitempty"`
// Set a secret reference, see config/secret.go. Used for setting an API keys.
Auth2 config.Secret `yaml:"auth,omitempty"`
// Optional configuration of the Driver. Some chains support different kinds of RPC.
Provider string `yaml:"provider,omitempty"`
CrosschainClient CrosschainClientConfig `yaml:"crosschain_client"`
// Does the chain rely on an indexer in addition to RPC? If so, the URL and type
// may be set here.
IndexerUrl string `yaml:"indexer_url,omitempty"`
IndexerType string `yaml:"indexer_type,omitempty"`
// Maximun depth to scan for transaction, if there is no index to use (substrate...)
MaxScanDepth int `yaml:"max_scan_depth,omitempty"`
NoGasFees bool `yaml:"no_gas_fees,omitempty"`
// Default gas budget to use for client gas estimation
GasBudgetDefault AmountHumanReadable `yaml:"gas_budget_default,omitempty"`
// Gas budget that cannot be exceeded below
GasBudgetMinimum AmountHumanReadable `yaml:"gas_budget_min,omitempty"`
// A remainder balance (e.g. rent threshold) that must be maintained after a transfer.
ReserveAmount AmountHumanReadable `yaml:"reserve_amount,omitempty"`
// A default for clients to gas price if there's not better way to estimate.
ChainGasPriceDefault float64 `yaml:"chain_gas_price_default,omitempty"`
// A local multiplier for client to apply to gas estimation, if it's important/needed.
ChainGasMultiplier float64 `yaml:"chain_gas_multiplier,omitempty"`
SecondaryChainGasMultiplier float64 `yaml:"secondary_chain_gas_multiplier,omitempty"`
// for gas estimation of gas limit, for somechains the simulation may be flaky and need a multiplier
ChainGasLimitMultiplier float64 `yaml:"chain_gas_limit_multiplier,omitempty"`
// The multiplier to apply to gas when there is a minimum replacement increase.
// This is used for EVM chains, to avoid the "replacement transaction underpriced" message.
// Normally it is 10%, but on chains like Base and Optimism, it seems to be at least 25% in practice.
ReplacementTransactionMultiplier float64 `yaml:"replacement_transaction_multiplier,omitempty"`
// The max/min prices can be set to provide sanity limits for what a gas price (per gas or per byte) should be.
// This should be in the blockchain amount.
ChainMaxGasPrice float64 `yaml:"chain_max_gas_price,omitempty"`
ChainMinGasPrice float64 `yaml:"chain_min_gas_price,omitempty"`
// Default gas limit for transactions
GasLimitDefault int `yaml:"gas_limit_default,omitempty"`
// TransactionActiveTime specifies the duration for which a transaction remains valid after being submitted.
// The value is represented as a `time.Duration` string.
// This field is currently used only by the Stellar network.
//
// Example format: "30s" (30 seconds), "2m" (2 minutes), "1h" (1 hour).
TransactionActiveTime time.Duration `yaml:"transaction_active_time,omitempty"`
// How many confirmations is considered "final" for this chain?
XConfirmationsFinal int `yaml:"confirmations_final,omitempty"`
Confirmations ConfirmationsConfig `yaml:"confirmations,omitempty"`
// Gas price oracle address
// Currently this is used for EVM L2 chains that have an additional "l1" fee.
GasPriceOracleAddress string `yaml:"gas_price_oracle_address,omitempty"`
// Rate limit setting on RPC requests for client, in requests/second.
RateLimit rate.Limit `yaml:"rate_limit,omitempty"`
// Period between requests (alternative to `rate_limit`)
PeriodLimit time.Duration `yaml:"period_limit,omitempty"`
// Number of requests to permit in burst
Burst int `yaml:"burst,omitempty"`
// Rate limiter configured from `rate_limit`, `period_limit`, `burst` (requires calling .Configure after loading from config)
Limiter *rate.Limiter `yaml:"-" mapstructure:"-"`
// HTTP timeout for the client (will default to global factory configuration)
HttpTimeout time.Duration `yaml:"http_timeout,omitempty"`
// Additional metadata. Not Used in crosschain itself, but helpful to enrich API endpoints.
External External `yaml:"external,omitempty"`
// Informational URLs for the chain explorers.
ExplorerUrls ExplorerUrls `yaml:"explorer_urls,omitempty"`
// If true, this means that the chain is not intended for future use and
// is only maintained for legacy purposes (by the upstream community).
// E.g. "Terra Classic" or "Fantom" are legacy chains that each have replacements.
Legacy bool `yaml:"legacy,omitempty"`
// Indicate to the driver if additional information should be included for older crosschain clients.
IncludeLegacyInformation bool `yaml:"include_legacy_information,omitempty"`
// If true, the client will only use confirmed UTXOs for unspent output queries.
ConfirmedUtxo bool `yaml:"confirmed_utxo,omitempty"`
}
func (*ChainClientConfig) Configure ¶
func (chain *ChainClientConfig) Configure()
func (*ChainClientConfig) NewClientLimiter ¶
func (chain *ChainClientConfig) NewClientLimiter() *rate.Limiter
type ChainConfig ¶
type ChainConfig struct {
*ChainBaseConfig `yaml:",inline"`
*ChainClientConfig `yaml:",inline"`
}
func NewChainConfig ¶
func NewChainConfig(nativeAsset NativeAsset, driverMaybe ...Driver) *ChainConfig
func (*ChainConfig) Base ¶
func (chain *ChainConfig) Base() *ChainBaseConfig
func (*ChainConfig) Client ¶
func (chain *ChainConfig) Client() *ChainClientConfig
func (*ChainConfig) ClientURL ¶
func (native *ChainConfig) ClientURL() (string, Driver)
Returns URL and driver used for the client. This will either Be the chain driver, or the 'special' crosschain driver.
func (*ChainConfig) Configure ¶
func (chain *ChainConfig) Configure(httpTimeout time.Duration)
func (*ChainConfig) DefaultHttpClient ¶
func (chain *ChainConfig) DefaultHttpClient() *http.Client
func (*ChainConfig) FindAdditionalNativeAsset ¶
func (native *ChainConfig) FindAdditionalNativeAsset(contract ContractAddress) (*AdditionalNativeAsset, bool)
func (*ChainConfig) GetAssetSymbol ¶
func (native *ChainConfig) GetAssetSymbol() string
func (*ChainConfig) GetChain ¶
func (asset *ChainConfig) GetChain() *ChainConfig
func (*ChainConfig) GetContract ¶
func (native *ChainConfig) GetContract() string
func (*ChainConfig) GetDecimals ¶
func (asset *ChainConfig) GetDecimals() int32
func (*ChainConfig) IsChain ¶
func (native *ChainConfig) IsChain(contract ContractAddress) bool
func (ChainConfig) String ¶
func (c ChainConfig) String() string
func (*ChainConfig) WithAuth ¶
func (chain *ChainConfig) WithAuth(auth config.Secret) *ChainConfig
func (*ChainConfig) WithChainCoin ¶
func (chain *ChainConfig) WithChainCoin(chainCoin string) *ChainConfig
func (*ChainConfig) WithChainID ¶
func (chain *ChainConfig) WithChainID(chainID string) *ChainConfig
func (*ChainConfig) WithChainPrefix ¶
func (chain *ChainConfig) WithChainPrefix(chainPrefix string) *ChainConfig
func (*ChainConfig) WithDecimals ¶
func (chain *ChainConfig) WithDecimals(decimals int32) *ChainConfig
func (*ChainConfig) WithDriver ¶
func (chain *ChainConfig) WithDriver(driver Driver) *ChainConfig
func (*ChainConfig) WithFeeLimit ¶
func (chain *ChainConfig) WithFeeLimit(feeLimit AmountHumanReadable) *ChainConfig
func (*ChainConfig) WithGasBudgetDefault ¶
func (chain *ChainConfig) WithGasBudgetDefault(gasBudgetDefault AmountHumanReadable) *ChainConfig
func (*ChainConfig) WithGasPriceMultiplier ¶
func (chain *ChainConfig) WithGasPriceMultiplier(multiplier float64) *ChainConfig
func (*ChainConfig) WithHttpTimeout ¶
func (chain *ChainConfig) WithHttpTimeout(httpTimeout time.Duration) *ChainConfig
func (*ChainConfig) WithIndexer ¶
func (chain *ChainConfig) WithIndexer(indexerType string, url string) *ChainConfig
func (*ChainConfig) WithMaxGasPrice ¶
func (chain *ChainConfig) WithMaxGasPrice(maxGasPrice float64) *ChainConfig
func (*ChainConfig) WithMinGasPrice ¶
func (chain *ChainConfig) WithMinGasPrice(minGasPrice float64) *ChainConfig
func (*ChainConfig) WithNet ¶
func (chain *ChainConfig) WithNet(net string) *ChainConfig
func (*ChainConfig) WithProvider ¶
func (chain *ChainConfig) WithProvider(provider string) *ChainConfig
func (*ChainConfig) WithTransactionActiveTime ¶
func (chain *ChainConfig) WithTransactionActiveTime(transactionActiveTime time.Duration) *ChainConfig
func (*ChainConfig) WithUrl ¶
func (chain *ChainConfig) WithUrl(url string) *ChainConfig
type ClientConfig ¶
type ClientConfig struct {
Driver Driver `yaml:"driver"`
URL string `yaml:"url,omitempty"`
Auth string `yaml:"auth,omitempty"`
Provider string `yaml:"provider,omitempty"`
Network NetworkSelector `yaml:"network,omitempty"`
}
ClientConfig is the model used to represent a client inside an AssetConfig
type ConfirmationsConfig ¶
type CrosschainClientConfig ¶
type CrosschainClientConfig struct {
Url string `yaml:"url"`
Network NetworkSelector `yaml:"network,omitempty"`
}
type Driver ¶
type Driver string
Driver is the type of a chain
func (Driver) PublicKeyFormat ¶
func (driver Driver) PublicKeyFormat() PublicKeyFormat
func (Driver) SignatureAlgorithms ¶
func (driver Driver) SignatureAlgorithms() []SignatureType
Returns the signature algorithms supported by the driver The first algorithm will be used as the default.
type ExplorerUrls ¶
type External ¶
type External struct {
Dti string `yaml:"dti,omitempty"`
CoinMarketCap struct {
// CoinMarketCap's ID for the chain
ChainId string `yaml:"chain_id,omitempty"`
// CoinMarketCap's ID for the chain's native asset, also called "UCID"
AssetId string `yaml:"asset_id,omitempty"`
} `yaml:"coin_market_cap,omitempty"`
CoinGecko struct {
// TODO: is there a chain ID for coingecko?
ChainId string `yaml:"chain_id,omitempty"`
// Coingecko's asset ID, if relevant
AssetId string `yaml:"asset_id,omitempty"`
} `yaml:"coin_gecko,omitempty"`
IndexingCo struct {
ChainId string `yaml:"chain_id,omitempty"`
Disabled bool `yaml:"disabled,omitempty"`
} `yaml:"indexing_co,omitempty"`
}
External ID's used by other vendors for the given chain
type GasFeePriority ¶
type GasFeePriority string
var Aggressive GasFeePriority = "aggressive"
var Low GasFeePriority = "low"
var Market GasFeePriority = "market"
var VeryAggressive GasFeePriority = "very-aggressive"
func NewPriority ¶
func NewPriority(input string) (GasFeePriority, error)
func (GasFeePriority) GetDefault ¶
func (p GasFeePriority) GetDefault() (decimal.Decimal, error)
func (GasFeePriority) IsEnum ¶
func (p GasFeePriority) IsEnum() bool
type ITask ¶
type ITask interface {
GetChain() *ChainConfig
GetDecimals() int32
// Informational / debugging
String() string
}
type MultiTransferInput ¶
type MultiTransferInput interface {
TxVariantInput
MultiTransfer()
}
Markers for each type of Variant Tx
type NativeAsset ¶
type NativeAsset string
NativeAsset is an asset on a blockchain used to pay gas fees. In Crosschain, for simplicity, a NativeAsset represents a chain.
func (NativeAsset) Driver ¶
func (native NativeAsset) Driver() Driver
func (NativeAsset) IsValid ¶
func (native NativeAsset) IsValid() bool
type NetworkSelector ¶
type NetworkSelector string
Network selector is used by crosschain client to select which network of a blockchain to select.
const Mainnets NetworkSelector = ""
const NotMainnets NetworkSelector = "!mainnet"
type PublicKeyFormat ¶
type PublicKeyFormat string
var Compressed PublicKeyFormat = "compressed"
var Raw PublicKeyFormat = "raw"
var Uncompressed PublicKeyFormat = "uncompressed"
type SignatureRequest ¶
type SignatureRequest struct {
// Required: The payload to sign
Payload []byte
// May be optionally set, if different from the from-address.
Signer Address
}
func NewSignatureRequest ¶
func NewSignatureRequest(payload []byte, signerMaybe ...Address) *SignatureRequest
type SignatureResponse ¶
type SignatureResponse struct {
// Signaure of the payload
Signature TxSignature
// Address + public key of the signer
PublicKey []byte
Address Address
}
type SignatureType ¶
type SignatureType string
type StakeTxInput ¶
type StakeTxInput interface {
TxVariantInput
Staking()
}
type StakingConfig ¶
type StakingConfig struct {
// the contract used for staking, if relevant
StakeContract string `yaml:"stake_contract,omitempty"`
// the contract used for unstaking, if relevant
UnstakeContract string `yaml:"unstake_contract,omitempty"`
// Compatible providers for staking
Providers []StakingProvider `yaml:"providers,omitempty"`
}
func (*StakingConfig) Enabled ¶
func (staking *StakingConfig) Enabled() bool
type StakingProvider ¶
type StakingProvider string
const Figment StakingProvider = "figment"
const Kiln StakingProvider = "kiln"
const Native StakingProvider = "native"
const Twinstake StakingProvider = "twinstake"
func (StakingProvider) Valid ¶
func (stakingProvider StakingProvider) Valid() bool
type StringOrInt ¶
type StringOrInt string
func (StringOrInt) AsInt ¶
func (s StringOrInt) AsInt() (uint64, bool)
func (StringOrInt) AsString ¶
func (s StringOrInt) AsString() string
type Tx ¶
type Tx interface {
Hash() TxHash
Sighashes() ([]*SignatureRequest, error)
SetSignatures(...*SignatureResponse) error
Serialize() ([]byte, error)
}
Tx is a transaction
type TxAdditionalSighashes ¶
type TxAdditionalSighashes interface {
// This is available in case a transaction needs to make signatures-over-signatures.
// This should return any _remaining_ signatures requests left to fill.
// The caller will always call .SetSignatures() after this with all of the signature made so far.
AdditionalSighashes() ([]*SignatureRequest, error)
}
type TxCall ¶
type TxCall interface {
Tx
// Set transaction input. This may not be needed, but could be used to adjust:
// * fees
// * other dynamic chain information not included in the origin Call message
SetInput(input CallTxInput) error
// List of addresses that may be needed to sign
SigningAddresses() []Address
// List of 3rd party contract addresses that this Call resource interacts with
// (omit native system contracts)
ContractAddresses() []ContractAddress
// Get original serialized message that Call was constructed with
GetMsg() json.RawMessage
}
type TxInput ¶
type TxInput interface {
GetDriver() Driver
TxInputConflicts
TxInputGasFeeMultiplier
TxInputGetMaxPossibleFee
}
TxInput is input data to a tx. Depending on the blockchain it can include nonce, recent block hash, account id, ...
type TxInputConflicts ¶
type TxInputConflicts interface {
// Test independence of two tx-inputs, assuming the same address is used.
// Examples:
// - using the same nonce or sequence is NOT independent
// - spending the same resources or utxo's is NOT independent
// - solana (using recent_block_hash) is pretty much always independent
// This is used to determine if a transaction needs to be queued or if it can be immediately signed & broadcasted.
IndependentOf(other TxInput) (independent bool)
// Test if tx-input could possibly result in a "double-send" given the history of past attempts.
// A double send is a user re-signing their transaction (to overcome a timeout or use new fees), but then risk multiple transactions
// landing on chain. A valid re-sign should only occur if it's only possible for one transaction to land out of the total set of attempts.
// Examples:
// - Solana typically has no conflicts, but need to ensure (a) new blockhash is used, and (b) sufficient time has passed
// to be sure a double send won't occur (return `true`).
// - If tx-inputs are not independent (spending same resources), then typically double-sends are impossible (and should return `true` here).
// - If there exists tx-inputs that are fully independent (and not timed out), then a double-send is possible and this should return false.
SafeFromDoubleSend(previousAttempts TxInput) (safe bool)
}
This interface determines whether if different tx inputs conflict with one another.
type TxInputEnvelope ¶
type TxInputEnvelope struct {
Type Driver `json:"type"`
}
func NewTxInputEnvelope ¶
func NewTxInputEnvelope(envType Driver) *TxInputEnvelope
type TxInputGasFeeMultiplier ¶
type TxInputGasFeeMultiplier interface {
SetGasFeePriority(priority GasFeePriority) error
}
type TxInputGetMaxPossibleFee ¶
type TxInputGetMaxPossibleFee interface {
// Get the maximum possible fee that could occur for this transaction.
// This is used to guard against "griefing" attacks where a user is charged way more than they intended.
// The contract address may be "" when the fee is for the native asset, as is often the case..
//
// Note: The caller/user should check this after TxInput has been populated with all other fields, as they can influence
// what the ultimate max fee is.
GetFeeLimit() (AmountBlockchain, ContractAddress)
}
type TxInputWithUnix ¶
type TxInputWithUnix interface {
SetUnix(int64)
}
For chains/transactions that can benefit from knowing the timestamp
type TxLegacyGetSignatures ¶
type TxLegacyGetSignatures interface {
// Replaced by TxWithMetadata.GetMetadata()
GetSignatures() []TxSignature
}
type TxSignature ¶
type TxSignature []byte
TxSignature is a tx signature
func NewTxSignatures ¶
func NewTxSignatures(data [][]byte) []TxSignature
NewTxSignatures creates a new array of TxSignature, useful to cast [][]byte into []TxSignature
type TxStatus ¶
type TxStatus uint8
TxStatus is the status of a tx on chain, currently success or failure.
type TxVariantInput ¶
type TxVariantInput interface {
TxInput
GetVariant() TxVariantInputType
}
type TxVariantInputType ¶
type TxVariantInputType string
func NewCallingInputType ¶
func NewCallingInputType(driver Driver) TxVariantInputType
func NewMultiTransferInputType ¶
func NewMultiTransferInputType(driver Driver, variant string) TxVariantInputType
func NewStakingInputType ¶
func NewStakingInputType(driver Driver, variant string) TxVariantInputType
func NewUnstakingInputType ¶
func NewUnstakingInputType(driver Driver, variant string) TxVariantInputType
func NewWithdrawingInputType ¶
func NewWithdrawingInputType(driver Driver, variant string) TxVariantInputType
func (TxVariantInputType) Driver ¶
func (variant TxVariantInputType) Driver() Driver
func (TxVariantInputType) Validate ¶
func (variant TxVariantInputType) Validate() error
func (TxVariantInputType) Variant ¶
func (variant TxVariantInputType) Variant() string
type TxWithMetadata ¶
type UnstakeTxInput ¶
type UnstakeTxInput interface {
TxVariantInput
Unstaking()
}
type WithdrawTxInput ¶
type WithdrawTxInput interface {
TxVariantInput
Withdrawing()
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
chain
|
|
|
cosmos/types/CosmWasm/wasmd/x/wasm/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/auction/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/exchange/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/insurance/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/ocr/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/oracle/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/peggy/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/permissions/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/tokenfactory/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/wasmx/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/evmos/evmos/v20/x/evm/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
cosmos/types/evmos/evmos/v20/x/feemarket/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
|
internet_computer/candid/internal/candid
Package candid is autogenerated by https://github.com/cordialsys/crosschain/chain/internet_computer/candid/upeg.
|
Package candid is autogenerated by https://github.com/cordialsys/crosschain/chain/internet_computer/candid/upeg. |
|
internet_computer/candid/internal/ctest
Package ctest is autogenerated by https://github.com/cordialsys/crosschain/chain/internet_computer/candid/upeg.
|
Package ctest is autogenerated by https://github.com/cordialsys/crosschain/chain/internet_computer/candid/upeg. |
|
internet_computer/candid/internal/cvalue
Package cvalue is autogenerated by https://github.com/cordialsys/crosschain/chain/internet_computer/candid/upeg.
|
Package cvalue is autogenerated by https://github.com/cordialsys/crosschain/chain/internet_computer/candid/upeg. |
|
kaspa/client/rest
Package rest provides primitives to interact with the openapi HTTP API.
|
Package rest provides primitives to interact with the openapi HTTP API. |
|
cmd
|
|
|
xc
command
|
|
|
examples/get_secret
command
|
|
|
examples
|
|
|
bitcoin
command
|
|
|
misc/solana_aux_token_account
command
|
|
|
staking
command
|
|
|
ton
command
|
|
|
txinfo
command
|
|
|
defaults/chains/example
command
|
|
|
pkg
|
|