Constructor
# new AkashicPay()
Do not call this constructor directly; instead, use the factory function
AkashicPay.build.
The class itself is only exported for developers who want to extend it.
Classes
Methods
# async static build(args) → {Promise.<AkashicPay.<Environment>>}
Construct and initialise a new AkashicPay instance.
Parameters:
Name | Type | Description |
---|---|---|
args |
APBuilderArgs.<Environment>
|
Differ depending on the environment property (i.e. APBuilderArgs.environment). In production, you must provide the L2-address of an Akashic-Link account, and either the corresponding private-key or recovery-phrase. In development, these arguments are optional; if not provided, a new OTK will be generated during initialisation. It can be retrieved with `.keyBackup` so that you may save it and supply it next time. |
Promise.<AkashicPay.<Environment>>
# async protected chooseBestACNode() → {Promise.<(ACNode|ACDevNode)>}
Finds an AkashicChain node to target for requests. If the chain is totally
healthy, the SDK will return the fastest node. Otherwise, it will return
the node least likely to experience consensus failures as the entry node.
The URL of an AC node on the network matching your environment
(production or development)
Promise.<(ACNode|ACDevNode)>
# async createDepositOrder(createDepositOrderParams) → {Promise.<ICreateDepositOrderResponse>}
Create deposit order
Parameters:
Name | Type | Description |
---|---|---|
createDepositOrderParams |
ICreateDepositOrder
|
Promise.<ICreateDepositOrderResponse>
# async getBalance() → {Promise.<Array.<IBalance>>}
Get total balances, divided by Network and Token.
Promise.<Array.<IBalance>>
# async getByOwnerAndIdentifier(getByOwnerAndIdentifierParams) → {Promise.<IGetByOwnerAndIdentifierResponse>}
Get key by BP and identifier
Parameters:
Name | Type | Description |
---|---|---|
getByOwnerAndIdentifierParams |
IGetByOwnerAndIdentifier
|
Promise.<IGetByOwnerAndIdentifierResponse>
# async getDepositAddress(network, identifier, referenceId) → {Promise.<IDepositAddress>}
Get an L1-address on the specified network for a user to deposit into
Parameters:
Name | Type | Description |
---|---|---|
network |
NetworkSymbol
|
L1-network |
identifier |
string
|
userID or similar identifier of the user |
referenceId |
string
|
optional referenceId to identify the order making the deposit |
Promise.<IDepositAddress>
# async getDepositUrl(identifier, referenceId) → {Promise.<string>}
Get deposit page url
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string
|
userID or similar identifier of the user |
referenceId |
string
|
optional referenceId to identify the order making the deposit |
Promise.<string>
# async getKeysByOwnerAndIdentifier(getKeysByOwnerAndIdentifierParams) → {Promise.<Array.<IKeyByOwnerAndIdentifier>>}
Get all keys by BP and identifier
Parameters:
Name | Type | Description |
---|---|---|
getKeysByOwnerAndIdentifierParams |
IGetKeysByOwnerAndIdentifier
|
Promise.<Array.<IKeyByOwnerAndIdentifier>>
# async getSupportedCurrencies() → {Promise.<Record.<string, Array>>}
Get the currently supported currencies in AkashicPay
Returns an object with the networks as the keys and a list of tokens as the values
Native coins (TRX, ETH, etc.) are not returned but always supported if the
network is supported
Promise.<Record.<string, Array>>
# async getTransactionDetails(l2TxHash) → {Promise.<(ITransaction|undefined)>}
Get details of an individual transaction. Returns undefined if no
transaction found for the queried hash
Parameters:
Name | Type | Description |
---|---|---|
l2TxHash |
string
|
L2 AkashicChain Hash of transaction |
Promise.<(ITransaction|undefined)>
# async getTransfers(getTransactionParams) → {Promise.<Array.<ITransaction>>}
Get all or a subset of transactions. Optionally paginated with `page` and `limit`.
Optional parameters: `layer`, `status`, `startDate`, `endDate`, `hideSmallTransactions`.
`hideSmallTransactions` excludes values below 1 USD
Parameters:
Name | Type | Description |
---|---|---|
getTransactionParams |
IGetTransactions
|
Promise.<Array.<ITransaction>>
# keyBackup() → {KeyBackup}
Get the OTK (One-Time-Key) object for this instance.
if the environment is production.
AkashicError
if the environment is development. This enables you to
easily create an OTK and re-use it in future tests or dev work.
# async lookForL2Address(aliasOrL1OrL2Address, network) → {Promise.<ILookForL2AddressResult>}
Check which L2-address an alias or L1-address belongs to. Or call with an
L2-address to verify it exists
Parameters:
Name | Type | Description |
---|---|---|
aliasOrL1OrL2Address |
string
|
|
network |
NetworkSymbol
|
Promise.<ILookForL2AddressResult>
# async payout(recipientId, to, amount, network, tokenopt) → {Promise.<IPayoutResponse>}
Send a crypto-transaction
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
recipientId |
string
|
userID or similar identifier of the user requesting the payout | |
to |
string
|
L1 or L2 address of receiver | |
amount |
string
|
Amount to send | |
network |
NetworkSymbol
|
L1-Network the funds belong to, e.g. `ETH` | |
token |
TokenSymbol
|
<optional> |
Optional. Include if sending token, e.g. `USDT` |
L2 Transaction hash of the transaction
or error if something went wrong
Promise.<IPayoutResponse>
# async protected setNewOTK() → {Promise.<void>}
Generates a new OTK and assigns it to `this.otk`. The OTK will live and die
with the lifetime of this AkashicPay instance.
Only for us in development/testing environments.
Promise.<void>
# protected setOtkFromKeyPair(privateKey, l2Address) → {void}
Sets your OTK to sign transactions on AkashicChain (AC)
Parameters:
Name | Type | Description |
---|---|---|
privateKey |
string
|
private key from Akashic Link. |
l2Address |
string
|
L2-address of your Akashic account |
void
# async protected setOtkFromRecoveryPhrase(recoveryPhrase, l2Address) → {Promise.<void>}
Sets your OTK to sign transactions on AkashicChain (AC)
Parameters:
Name | Type | Description |
---|---|---|
recoveryPhrase |
string
|
The recovery phrase generated when you created your Akashic Link account. |
l2Address |
string
|
L2-address of your Akashic account |
Promise.<void>