akashicpay

package module
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 21 Imported by: 0

README

AkashicPay - Go SDK

A library to interact with the AkashicChain network for Go.

Installing

Install the package with:

go get github.com/akashicpay/akashicpay-go

Usage

Features

  • Send crypto via Layer 1 and Layer 2 (Akashic Chain)
  • Create wallets for your users into which they can deposit crypto
  • Fetch balance and transaction details
  • Completely Web3: No login or API-key necessary. Just supply your Akashic private key, which stays on your server. The SDK signs your transactions with your key and sends them to Akashic Chain.
  • Supports Ethereum and Tron

Getting Started

  1. Create an account on AkashicLink (Google Chrome Extension or iPhone/Android App)
  2. Visit AkashicPay and connect with AkashicLink. Set up the URL(s) you wish to receive callbacks for.
  3. Integrate the SDK in your code. Example:
import (
    "os"

    akashicpay "github.com/akashic/go-sdk"
)
// use whatever secret management tool you prefer to load the private key
// from your AkashicLink account. It should be of the form:
// "0x2d99270559d7702eadd1c5a483d0a795566dc76c18ad9d426c932de41bfb78b7"
apKey := os.Getenv("ApKey")
// this is the address of your AkashicLink account. Of the form "AS1234..."
apL2Address := os.Getenv("ApL2Address")

// in development, you will use our testnet and testnet L1 chains
env := os.Getenv("Environment")
apEnv := akashicpay.Development

if env == "Prod" {
  apEnv = akashicPay.Production
}

// instantiate an SDK instance, ready to use
ap, err := akashicpay.NewAkashicPay(apKey, apL2Address, apEnv, "")

AkashicPay is now fully setup and ready to use.

Testing

You can also use AkashicPay with the AkashicChain Testnet & Sepolia (Ethereum) and Shasta (Tron) testnets, useful for local development and preprod environments. To do this, follow the same procedure as above but make sure you use testnet versions of AkashicLink and AkashicPay. Make sure you use the development environment in the SDK:

import (
	"os"

	akashicpay "github.com/akashic/go-sdk"
)

apKey := os.Getenv("ApTestKey")
apL2Address := os.Getenv("ApTestL2Address")

// in development, you will use our testnet and testnet L1 chains
apEnv := akashicpay.Development

// instantiate an SDK instance, ready to use
ap, err := akashicpay.NewAkashicPay(apKey, apL2Address, apEnv, "")

if err != nil {
// handle error
}

You can now create an L1-wallet on a testnet:

dA, err := ap.GetDepositAddress(akashicpay.Tron_Shasta, "user123", "")

Faucet

During testing and local development, you need cryptocurrency on the testnets to do anything meaningful. Akashic provides a simple faucet where you can request some coins and tokens on Shasta and Sepolia by supplying your L2-address/identity: https://faucet.testnet.akashicchain.com/ If you require further funds, the official Tron Discord provides users with either 5000 TRX or USDT on Shasta every day.

You can check to see if your balance has increased with:

balance, err := ap.GetBalance()
// -> [{networkSymbol: 'TRX-SHASTA', balance: '5000'}, ...]

Documentation

For more in-depth documentation describing the SDKs functions in detail, explanations of terminology, and guides on how to use AkashicPay.com, click here

License

This project is licensed under the MIT License

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

Constants

This section is empty.

Variables

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 IGetExchangeRatesResult map[string]string

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 ILookForL2AddressResponse

type ILookForL2AddressResponse struct {
	L2Address string `json:"l2Address,omitempty"`
	Alias     string `json:"alias,omitempty"`
}

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 InternalFee struct {
	Deposit  string `json:"deposit,omitempty"`
	Withdraw string `json:"withdraw,omitempty"`
}

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 Otk

type Otk struct {
	Identity string
	// contains filtered or unexported fields
}

type RequestedValue

type RequestedValue struct {
	Amount   string   `json:"amount"`
	Currency Currency `json:"currency"`
}

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"
)

type UserInfo

type UserInfo struct {
	Identity   string `json:"identity"`   // Akashic address
	WalletType string `json:"walletType"` // Internal. Can be ignored
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL