Documentation
¶
Overview ¶
Package akashicpay provides functions to easily interact with the AkashicChain network
This includes making payouts, creating wallets for deposits, and querying transaction-details
Index ¶
- Variables
- type AkashicError
- type AkashicErrorCode
- type AkashicPay
- func (ap *AkashicPay) GetBalance() ([]Balance, error)
- func (ap *AkashicPay) GetDepositAddress(network NetworkSymbol, identifier string, referenceId string) (IDepositAddress, error)
- func (ap *AkashicPay) GetDepositAddressWithRequestedValue(network NetworkSymbol, identifier string, referenceId string, ...) (IDepositAddress, error)
- func (ap *AkashicPay) GetDepositUrl(identifier string, referenceId string, receiveCurrencies []CryptoCurrency, ...) (string, error)
- func (ap *AkashicPay) GetDepositUrlWithRequestedValue(identifier string, referenceId string, receiveCurrencies []CryptoCurrency, ...) (string, error)
- func (ap *AkashicPay) GetExchangeRates(requestedCurrency Currency) (IGetExchangeRatesResult, error)
- func (ap *AkashicPay) GetSupportedCurrencies() (map[CryptoCurrency][]NetworkSymbol, error)
- func (ap *AkashicPay) GetTransactionDetails(l2Hash string) (ITransaction, error)
- func (ap *AkashicPay) GetTransfers(getTransactionParams IGetTransactions) ([]ITransaction, error)
- func (ap *AkashicPay) LookForL2Address(aliasOrL1OrL2Address string, network NetworkSymbol) (ILookForL2AddressResponse, error)
- func (ap *AkashicPay) Payout(referenceId string, to string, amount string, network NetworkSymbol, ...) (string, error)
- func (ap *AkashicPay) VerifySignature(callback string, signature string) (bool, error)
- type Balance
- type CryptoCurrency
- type Currency
- type DepositRequest
- type Environment
- type IDepositAddress
- type IGetExchangeRatesResult
- type IGetTransactions
- type ILookForL2AddressResponse
- type ITransaction
- type InternalFee
- type NetworkSymbol
- type Otk
- type RequestedValue
- type TokenSymbol
- type TransactionLayer
- type TransactionStatus
- type TransactionType
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
var NonEthEvmNetworks = []NetworkSymbol{Binance_Smart_Chain_Mainnet, Binance_Smart_Chain_Testnet}
NonEthEvmNetworks represents non-Ethereum EVM networks
Functions ¶
This section is empty.
Types ¶
type AkashicError ¶
type AkashicError struct {
Code AkashicErrorCode // Short error string
Details string // Longer explanation of the error
}
Custom error that implements the `error` interface
func (*AkashicError) Error ¶
func (e *AkashicError) Error() string
type AkashicErrorCode ¶
type AkashicErrorCode string
const ( AkashicErrorCodeTestNetOtkOnboardingFailed AkashicErrorCode = "OTK_ONBOARDING_FAILED" AkashicErrorCodeIncorrectPrivateKeyFormat AkashicErrorCode = "INVALID_PRIVATE_KEY_FORMAT" AkashicErrorCodeUnknownError AkashicErrorCode = "UNKNOWN_ERROR" AkashicErrorCodeKeyCreationFailure AkashicErrorCode = "WALLET_CREATION_FAILURE" AkashicErrorCodeUnHealthyKey AkashicErrorCode = "UNHEALTHY_WALLET" AkashicErrorCodeAccessDenied AkashicErrorCode = "ACCESS_DENIED" AkashicErrorCodeL2AddressNotFound AkashicErrorCode = "L2ADDRESS_NOT_FOUND" AkashicErrorCodeIsNotBp AkashicErrorCode = "NOT_SIGNED_UP" AkashicErrorCodeSavingsExceeded AkashicErrorCode = "FUNDS_EXCEEDED" AkashicErrorCodeAssignmentFailed AkashicErrorCode = "ASSIGNMENT_FAILED" AkashicErrorCodeNetworkEnvironmentMismatch AkashicErrorCode = "NETWORK_ENVIRONMENT_MISMATCH" AkashicErrorCodeDecimalLimitExceeded AkashicErrorCode = "TOKEN_DECIMAL_LIMIT_EXCEEDED" )
type AkashicPay ¶
type AkashicPay struct {
TargetNode acNode
Env Environment
ApiSecret string
// contains filtered or unexported fields
}
func NewAkashicPay ¶
func NewAkashicPay(privateKey string, identity string, env Environment, apiSecret string) (*AkashicPay, error)
Construct and initialize a new AkashicPay instance. Returns a pointer to an AkashicPay instance
func (*AkashicPay) GetBalance ¶
func (ap *AkashicPay) GetBalance() ([]Balance, error)
Get total balances, divided by Network and Token
func (*AkashicPay) GetDepositAddress ¶
func (ap *AkashicPay) GetDepositAddress(network NetworkSymbol, identifier string, referenceId string) (IDepositAddress, error)
GetDepositAddress returns an L1-address on the specified network for a user to deposit into
referenceId is a parameter used to identify the order, can be left out ("")
func (*AkashicPay) GetDepositAddressWithRequestedValue ¶
func (ap *AkashicPay) GetDepositAddressWithRequestedValue(network NetworkSymbol, identifier string, referenceId string, requestedCurrency Currency, requestedAmount string, token TokenSymbol, markupPercentage float64) (IDepositAddress, error)
Same as GetDepositAddress, but requires specifying the value of the deposit via requestedCurrency and requestedAmount
unlike GetDepositUrl, referenceId must be specified
Set the markupPercantage to adjust the exchange-rate for a markup/discount
func (*AkashicPay) GetDepositUrl ¶
func (ap *AkashicPay) GetDepositUrl(identifier string, referenceId string, receiveCurrencies []CryptoCurrency, networks []NetworkSymbol, redirectUrl string) (string, error)
GetDepositUrl returns a url where a user can make deposits
receiveCurrencies specifies which currencies you would like displayed as options on the page
networks specifies which networks you would like displayed as options on the page
referenceId is a parameter used to identify the order, can be left out ("")
redirectUrl is a parameter which sets a URL to redirect to from the deposit URL, can be left out ("")
func (*AkashicPay) GetDepositUrlWithRequestedValue ¶
func (ap *AkashicPay) GetDepositUrlWithRequestedValue(identifier string, referenceId string, receiveCurrencies []CryptoCurrency, networks []NetworkSymbol, redirectUrl string, requestedCurrency Currency, requestedAmount string, markupPercentage float64) (string, error)
Same as GetDepositUrl, but requires specifying the value of the deposit via requestedCurrency and requestedAmount
unlike GetDepositUrl, referenceId must be specified
Set the markupPercantage to adjust the exchange-rate for a markup/discount
func (*AkashicPay) GetExchangeRates ¶
func (ap *AkashicPay) GetExchangeRates(requestedCurrency Currency) (IGetExchangeRatesResult, error)
GetExchangeRates return the exchange rates for all supported main-net coins in the value of the requested currency
func (*AkashicPay) GetSupportedCurrencies ¶
func (ap *AkashicPay) GetSupportedCurrencies() (map[CryptoCurrency][]NetworkSymbol, error)
Get the currently supported currencies in AkashicPay Returns a map from currencies to a list of networks supported for that currency
func (*AkashicPay) GetTransactionDetails ¶
func (ap *AkashicPay) GetTransactionDetails(l2Hash string) (ITransaction, error)
GetTransactionDetails returns details about an individual transactions
Returns an empty interface if no transaction found
func (*AkashicPay) GetTransfers ¶
func (ap *AkashicPay) GetTransfers(getTransactionParams IGetTransactions) ([]ITransaction, error)
Get all or a subset of transactions.
Specify Page and Limit for pagination
func (*AkashicPay) LookForL2Address ¶
func (ap *AkashicPay) LookForL2Address(aliasOrL1OrL2Address string, network NetworkSymbol) (ILookForL2AddressResponse, error)
LookForL2Address checks which L2-address an alias or L1-address belongs to. Or call with an L2-address to verify it exists
func (*AkashicPay) Payout ¶
func (ap *AkashicPay) Payout(referenceId string, to string, amount string, network NetworkSymbol, token TokenSymbol) (string, error)
Send a crypto-transaction
referenceId is the userId or similar identifier for identifying the transaction
to is the L1 or L2 address of the receiver
Supply a zero-valued token to send native coin ("")
The return is the L2 hash of the transaction
func (*AkashicPay) VerifySignature ¶
func (ap *AkashicPay) VerifySignature(callback string, signature string) (bool, error)
VerifySignature can be used to verify a callback has not been altered. You must have initiated the SDK with your API-secret to do this
Supply the callback-body as a string (`{"amount": "1", ...}`) and the signature from the callback-header
Returns true if valid, indicating the callback has not been altered
type Balance ¶
type Balance struct {
NetworkSymbol NetworkSymbol
TokenSymbol TokenSymbol
Balance string
}
type CryptoCurrency ¶
type CryptoCurrency string
const ( CryptoUSDT CryptoCurrency = "USDT" CryptoUSDC CryptoCurrency = "USDC" CryptoTRX CryptoCurrency = "TRX" CryptoETH CryptoCurrency = "ETH" CryptoSEP CryptoCurrency = "SEP" )
Currencies supported by AkashicPay, includes native coins and tokens
type Currency ¶
type Currency string
const ( CurrencyUSDT Currency = "USDT" CurrencyUSDC Currency = "USDC" CurrencyTRX Currency = "TRX" CurrencyETH Currency = "ETH" CurrencyBNB Currency = "BNB" CurrencySOL Currency = "SOL" CurrencyCHF Currency = "CHF" CurrencyCNY Currency = "CNY" CurrencyEUR Currency = "EUR" CurrencyHKD Currency = "HKD" CurrencyIDR Currency = "IDR" CurrencyJPY Currency = "JPY" CurrencyKHR Currency = "KHR" CurrencyKRW Currency = "KRW" CurrencyMYR Currency = "MYR" CurrencyPHP Currency = "PHP" CurrencySGD Currency = "SGD" CurrencyTHB Currency = "THB" CurrencyTWD Currency = "TWD" CurrencyUSD Currency = "USD" CurrencyVND Currency = "VND" )
Fiat- and Crypto-currencies for setting amounts in deposit-orders
type DepositRequest ¶
type DepositRequest struct {
Id string `json:"id"` // Internal Id. Can be ignored
RequestedValue RequestedValue `json:"requestedValue"` // Requested value, amount and currency
ExchangeRate string `json:"exchangeRate,omitempty"` // What the received currency is worth in the requested currency
}
type Environment ¶
type Environment string
const ( Development Environment = "Development" Production Environment = "Production" )
type IDepositAddress ¶
type IDepositAddress struct {
Address string // Address (L1) that can be transferred to
Identifier string // userId or similar which will be identified with deposits to this address
ReferenceId string
RequestedAmount string
RequestedCurrency Currency
Network NetworkSymbol
Token TokenSymbol
ExchangeRate string // Exchange rate of requestedCurrency vs deposit currency
Amount string
Expires string
MarkupPercentage string // Markup percentage to be applied to the exchange rate
}
type IGetExchangeRatesResult ¶
type IGetTransactions ¶
type IGetTransactions struct {
Page int // Page, for pagination
Limit int // Limit for pagination, only accepts 10, 25, 50, or 100
StartDate time.Time // To only include transactions after this time
EndDate time.Time // To only include transactions before this time
Layer TransactionLayer // Transaction layer: 'L1' or 'L2'
Status TransactionStatus // Transaction status: Pending, Confirmed, or Failed
TransactionType TransactionType // Transaction type: Deposit or Withdrawal (Payout)
HideSmallTransactions bool // Excludes transactions below 1 USD in value
Identifier string // Optional identifier to filter transactions by user
ReferenceId string // Optional reference ID to filter transactions
}
type ITransaction ¶
type ITransaction struct {
FromAddress string `json:"fromAddress"`
ToAddress string `json:"toAddress"`
Layer TransactionLayer `json:"layer"` // Transaction-layer: L1 or L2
InitiatedAt string `json:"initiatedAt"` // Date in ISO8601 format
ConfirmedAt string `json:"confirmedAt"` // Confirmed Date in ISO8601 format
Amount string `json:"amount"`
CoinSymbol NetworkSymbol `json:"coinSymbol"` // Network (L1) of transaction
Status TransactionStatus `json:"status"`
TxHash string `json:"txHash,omitempty"` // Network's hash if L1. Not present for L2
FeesPaid string `json:"feesPaid,omitempty"` // Gas Fee paid on network. Not present for L2
L2TxnHash string `json:"l2TxnHash,omitempty"` // Akashic Transaction Hash. For both L1 and L2
TokenSymbol TokenSymbol `json:"tokenSymbol,omitempty"` // Present only if token-transaction
InternalFee InternalFee `json:"internalFee"` // Akshic Fee
Identifier string `json:"identifier,omitempty"` // User-identifier for deposits
ReferenceId string `json:"referenceId,omitempty"` // Reference-Id to identify a deposit
DepositRequest DepositRequest `json:"depositRequest"` // If a specific value was requested for a deposit, this is included
ReceiverInfo UserInfo `json:"receiverInfo,omitempty"` // Information about receiving user, for a deposit
SenderInfo UserInfo `json:"senderInfo,omitempty"` // Information about receiving user, for a withdrawal
FeeIsDelegated bool `json:"feeIsDelegated,omitempty"` // Whether network-fee was delegated to a token-fee
}
type InternalFee ¶
type NetworkSymbol ¶
type NetworkSymbol string
const ( Tron NetworkSymbol = "TRX" Tron_Shasta NetworkSymbol = "TRX-SHASTA" Ethereum_Mainnet NetworkSymbol = "ETH" Ethereum_Sepolia NetworkSymbol = "SEP" Binance_Smart_Chain_Mainnet NetworkSymbol = "BNB" Binance_Smart_Chain_Testnet NetworkSymbol = "tBNB" Solana NetworkSymbol = "SOL" Solana_Devnet NetworkSymbol = "SOLDEV" )
Network supported by AkashicPay, test- and mainnets
type RequestedValue ¶
type TokenSymbol ¶
type TokenSymbol string
const ( USDT TokenSymbol = "USDT" USDC TokenSymbol = "USDC" )
Tokens supported by AkashicPay
type TransactionLayer ¶
type TransactionLayer string
const ( L1 TransactionLayer = "L1Transaction" L2 TransactionLayer = "L2Transaction" )
type TransactionStatus ¶
type TransactionStatus string
const ( PENDING TransactionStatus = "Pending" CONFIRMED TransactionStatus = "Confirmed" FAILED TransactionStatus = "Failed" )
type TransactionType ¶
type TransactionType string
const ( DEPOSIT TransactionType = "Deposit" WITHDRAWAL TransactionType = "Withdrawal" )