alphadex-sdk-js
v0.12.15
Published
AlphaDEX Javascritp SDK
Downloads
162
Readme
alphadex-sdk-js (AlphaDEX Javascript SDK)
alphadex-sdk-js is a typescript/javascript package to help developers integrate effortlessly with the AlphaDEX decentralised exchange on Radix DLT
It provides developers with easy access to the live data on the AlphaDEX exchange as well as a number of convenience functions and classes/types for working with the exchange.
Interesting note: alphadex-sdk-js connects to the AlphaDEX Websocket server to provide the live data feed without any intervention needed from the developer.
Installation
Node.js and NPM
You will need node.js and npm (node package manager) installed on your machine in order to add alphadex-sdk-js to your project. If you do not yet have it installed, you can find instructions to do so here
Add alphadex-sdk-js to your project
To add alphadex-sdk-js to your project, run the following command from the root directory of your project:
npm install --save alphadex-sdk-js
Updating the SDK
Update to latest patch (non-breaking changes)
To update the SDK for any new changes that are non-breaking (either bug fixes or feature additions), you can run the following command in your project directory:
npm update alphadex-sdk-js
Update to latest version (including breaking changes)
To update the SDK to the very latest version (which might include breaking changes), you can run the following command in your project directory:
npm install --save alphadex-sdk-js@latest
Usage
Import required variables and functions
To use alphadex-sdk-js in your project, you need to import at least the init function and the clientState object. You will need to import and run the init function in the first file that executes (e.g. index.js).
For ease of use it is suggested to import all the alphadex-sdk-js functions and variables as one combined reference (e.g. adex, but you can choose any name). This has the benefit that it clearly distinguishes the AlphaDEX SDK functions from your app's own native functions and will provide auto-complete functionality in your editor to help you choose the appropraite function.
Example: Import all AlphaDEX SDK functions and variables as one reference called adex.
import * as adex from "alphadex-sdk-js";
Alternatively you can import each function and variable individually.
Example: Import functions and variables individually.
import { init, clientState } from "alphadex-sdk-js";
Initialize the AlphaDEX SDK
In order to connect the AlphaDEX SDK to the live data on the AlphaDEX exchange you need to run the init function in the root file of your project (e.g. index.js). This function will connect to the AlphaDEX websocket server and ensure that the sdk variables are kept in sync with the live data on the exchange.
Example: Run the init function to initialize the sdk connection with the AlphaDEX exchange (using combined import as adex).
// import all the sdk functions and variables as adex
import * as adex from "alphadex-sdk-js";
...
// run the sdk init function to establish a live connection with the exchange
adex.init();
// use the variables with the live data in your program/app
let adexState = adex.clientState;
console.log("Status of the alphadex sdk connection: "+adexState.status);
Example: Run the init function to initialize the sdk connection with the AlphaDEX exchange (using individual imports).
// import init function and clientState variable individually
import { clientState, init } from "alphadex-sdk-js";
...
// run the sdk init function to establish a live connection with the exchange
init();
// use the variables with the live data in your program/app
let adexState = clientState;
console.log("Status of the alphadex sdk connection: "+adexState.status);
Using variables in alphadex-sdk-js
alphadex-sdk-js gives the developer access to a number of variables that are constantly updated to reflect the latest state of the AlphaDEX exchange.
All variables have a static and observable version (indicated by a $ at the end of the variable name).
Example: static and observable version of a variable
let staticStatus = adex.clientState.status;
let observableStatus = adex.clientState.status$;
All these variables are provided in one object called clientState.
clientState object
The clientState object holds all variables that reflect the live state of the AlphaDEX exchange. This object must be initialized by calling the init function.
Example: Calling the init function to initialize the clientState object and assigning the clientState object to a local variable myAdexState.
import * as adex from "alphadex-sdk-js";
// call the init function to connect to the AlphaDEX exchange
// and initialize the clientState object
adex.init();
// assign the clientState object to a local variable
let myAdexState = adex.clientState;
Variables
All the variables below are accessed as fields of the clientState object.
Example: How to access a variable.
// Accessing the status variable
let connectionStatus = adex.clientState.status
Read + Write Variables
These variables can be changed by the user. When the variables are changed they will automatically cause all related variables to update automatically.
| Variable | Type | Description | Access | | -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | | alphadexApiServerUrl($) | string | The URL of the Api/Websocket server that the SDK is connected to. | Read + Write | | currentCandlePeriod($) | string | The currently selected candle period. Candle data is used for candlestick charts. This variable can be changed by the user, but must be one of the valid values specified in CandlePeriods. | Read + Write | | currentPairAddress($) | string | The on-ledger component address of the currently selected AlphaDEX pair. alphadex-sdk-js will provide live updated details of various variables associated with the currently selected pair. The user can change this variable to another pair address and all the variables associated with the current pair will automatically update for the new pair. | Read + Write | | getAllPairsMarketData($) | boolean | Flag that indicates whether the market data for all pairs on AlphaDEX should be kept updated. Be aware that when this flag is true it could use a lot of bandwith. It is suggested to only set it to true when required. | Read + Write | | stateChangeFrequency | number | The number of milliseconds between state change emits from the stateChanged$ observable variable. Setting this value to 0, will effectively mean that all state changes are emitted individually. The default for this variable is 500 i.e. the stateChanged$ observable will emit the latest state every half second. | Read + Write |
Read Only Variables
| Variable | Type | Description | Access | | --------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | | stateChanged$ | Observable <StaticState> | Observable that gets emitted every time one of the AlphaDEX variables change. This observable is useful for applications that need to manually update their state variables. It emits a StaticState object that contains read-only versions of the AlphaDEX variables (similar to the clientState object, but no variables can be changed). | Read Only | | alphadexAddress($) | string | The on-ledger component address of the AlphaDEX exchange component. | Read Only | | adminBadgeAddress($) | string | The on-ledger resource address of the AlphaDEX Admin badge. AlphaDEX Admin badges are used to identify accounts that have admin permissions on the AlphaDEX exchange. | Read Only | | maxPlatformFee($) | number | The maximum fee that platforms/apps can specify as their platform fee (expressed in decimals). E.g. alphadexMaxPlatformFee = 0.001 (0.1%) | Read Only | | currentPairCandlesList($) | Array of Candle | A sorted list of the candle (open, close, high, low) history for the currently selected AlphaDEX pair using the candle period specified by the currentCandlePeriod variable. | Read Only | | currentPairInfo($) | PairInfo | Basic information about the currently selected AlphaDEX pair. This variable will automatically update when currentPairAddress is changed. | Read Only | | currentPairOrderbook($) | Orderbook | Orderbook information about the currently selected AlphaDEX pair. This variable will automatically update when currentPairAddress is changed. | Read Only | | currentPairTrades($) | Array of Trade | List of most recent trades for the currently selected AlphaDEX pair. The number of trades in the list is determined by the value of the maxTrades variable. This variable will automatically update when currentPairAddress is changed. | Read Only | | epochsPerPeriod($) | number | The number of epochs between AlphaDEX pairs checking to see if they need to update their liquidity fee. | Read Only | | allowRecallableTokens($) | boolean | Indicates whether recallable tokens are allowed in new pairs on the exchange | Read Only | | allowFreezableTokens($) | boolean | Indicates whether freezable tokens are allowed in new pairs on the exchange | Read Only | | exchangeFee($) | number | The portion of the fee due to the AlphaDEX exchange on every trade (expressed in decimals). E.g. alphadexExchangeFee = 0.0005 (0.05%) | Read Only | | newPairFee($) | number | The cost in XRD to create a new pair on AlphaDEX. | Read Only | | pairsList($) | Array of PairInfo | An array/list of all the pairs listed on the AlphaDEX exchange. The list is not sorted in any particular order. | Read Only | | pairsMap($) | Map<string, PairInfo> | A map of all the pairs listed on the AlphaDEX exchange, indexed by the pair's on-ledger component address. | Read Only | | platformBadgeAddress($) | string | The on-ledger resource address of the AlphaDEX Platform badge. AlphaDEX Platform badges are issued to platforms/apps that will submit orders to the AlphaDEX exchange. Each badge holds information about the platform and the platform fee for submitting orders. | Read Only | | priceMaxDecimals($) | number | The maximum number of decimal digits allowed in any AlphaDEX price. | Read Only | | priceSignificantDigits($) | number | The number of significant digits to allow in an AlphaDEX price. | Read Only | | status($) | ClientStatus | Shows the status of the connection with the AlphaDEX exchange. Can be one of 3 values: "LOADING", "READY", "OFFLINE" | Read Only | | tokensList($) | Array of TokenInfo | An array/list of all the tokens listed on the AlphaDEX exchange. The list is not sorted in any particular order. | Read Only | | tokensMap($) | Map<string, TokenInfo> | A map of all the tokens listed on the AlphaDEX exchange, indexed by the token's on-ledger resource address. | Read Only | | xrdAddress($) | string | The on-ledger resource address of the XRD (Radix) token. This address is used to uniquely identify the XRD token. | Read Only |
Functions List
Setup Functions
Functions to initialize and destroy the SDK connection to the AlphaDEX exchange. | Function Name | Description | | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------- | | init | Connects SDK to AlphaDEX exchange and initializes the clientState object. | | destroy | Stops SDK connection with AlphaDEX exchange and resets clientState object. |
Create Transaction Functions
Functions that create a transaction manifest that can be submitted to a user wallet for signing. | Function Name | Description | | ----------------------------------------------------------------------------------- | ----------- | | createCancelOrderTx | Create a transaction manifest for cancelling an exchange order. | | createExchangeOrderTx | Create a transaction manifest for an exchange order. | | createNewPlatformBadgeTx | Create a transaction manifest to create a new platform badge. | | createChangePlatformFeeTx | Create a transaction manifest to change the fee of a platform badge. | | createChangePlatformNameTx | Create a transaction manifest to change the name of a platform badge. | | createNewPairTx | Create a transaction manifest to create a new pair. | | createSwapTx | Create a transaction manifest for a swap. |
Submit Transaction Functions
Functions that submit a transaction directly to the user wallet for signing.
| Function Name | Description | | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | | submitCancelOrder | Transaction to cancel an exchange order. | | submitExchangeOrder | Transaction to create a new exchange order. | | submitNewPlatformBadgeTx | Transaction to create a new platform badge. | | submitChangePlatformFeeTx | Transaction to change the fee of a new platform badge. | | submitChangePlatformNameTx | Transaction to change the name of a new platform badge. | | submitNewPairTx | Transaction to create a new pair | | submitSwap | Transaction to submit a new swap | | submitTransaction | Utility function to submit any transaction manifest to the user wallet |
Get Data Functions
Functions that fetch AlphaDEX related data from a specific account or set of accounts or the ledger.
| Function Name | Description | | ------------------------------------------------------------------------------------- | ---------------------------------------------------- | | getAccountOrders | Gets all order receipts in the specified account | | getPairOrders | Gets specified order receipts for the specified pair | | getPlatformBadges | Gets all platform badges in the specified accounts | | getPlatformBadgeInfo | Gets platform badge info for a specified platform id |
Get Quotes Functions
Functions that provide an estimated quote of tokens received and exchange costs for a planned order/swap. Useful to show a user the estimated outcome of an order/swap.
| Function Name | Description | | --------------------------------------------------------------------------------------- | ------------------------------------- | | getExchangeOrderQuote | Estimated quote for an exchange order | | getSwapQuote | Estimated quote for a swap |
Functions Details
init() [async function] (back to Functions List)
Function that connects the SDK to the AlphaDEX exchange websocket server and initializes the clientState object.
Parameters:
| Parameter | Description | Type | Example | | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | --------- | | alphadexApiNetwork (optional) | The type of AlphaDEX api/websocket server the SDK must connect to. If not specified it will use "mainnet". | ApiNetwork | "mainnet" | | alphadexApiVersion (optional) | The version of the alphadex API to use. If not specified it will use "v0". "v0" is the only current API version available. | string | "v0" |
Returns: Promise of SDKResult
Successful SDKResult data field : nothing
destroy() (back to Functions List)
Function that disconnects the SDK from the AlphaDEX exchange websocket server and clears the clientState object.
It is suggested to call this function when a live connection to the AlphaDEX exchange is no longer needed or when the user exits your app.
Parameters: None
Returns: Nothing
getExchangeOrderQuote() [async function] (back to Functions List)
Function that returns an estimated quote for a new AlphaDEX exchange order.
Parameters:
| Parameter | Description | Type | Example | | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | ---------------------------- | | pairAddress | The on-ledger component address of the AlphaDEX pair for this order. | string | "component_7t45r624hjfguyfr" | | orderType | The type of order. Valid values = "LIMIT", "POST-ONLY", "MARKET". | OrderType or string | OrderType.LIMIT or "LIMIT" | | side | The side for the order. Valid values = "BUY", "SELL". | OrderSide or string | OrderSide.BUY or "BUY" | | tokenAddress | The on-ledger resource address of the specified token for the order. | string | "resource_634gafe55ey8674j" | | amount | The amount of the token to process in the order | number | 12.54 | | platformId | The platform id for the order. Specified in decimals | number | 0.001 | | price | (ignored if set to -1) The price limit to apply for the order. Either price or slippage must be specified. | number | 4.657 | | slippage | (ignored if set to -1) The amount of price slippage that can be tolerated for the order, specified in decimals. Either price or slippage must be specified. | number | 0.05 |
Returns: Promise of SDKResult
Successful SDKResult data field : Quote (Estimated outcome of the specified exchange transaction)
createExchangeOrderTx() [async function] (back to Functions List)
Function to create a transaction manifest for creating a new AlphaDEX exchange order.
Parameters:
| Parameter | Description | Type | Example | | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | ---------------------------- | | pairAddress | The on-ledger component address of the AlphaDEX pair for this order. | string | "component_7t45r624hjfguyfr" | | orderType | The type of order. Valid values = "LIMIT", "POST-ONLY", "MARKET". | OrderType or string | OrderType.LIMIT or "LIMIT" | | side | The side for the order. Valid values = "BUY", "SELL". | OrderSide or string | OrderSide.BUY or "BUY" | | tokenAddress | The on-ledger resource address of the specified token for the order. | string | "resource_634gafe55ey8674j" | | amount | The amount of the token to process in the order | number | 12.54 | | price | (ignored if orderType = "MARKET", set to -1) The price at which to submit the order. | number | 4.657 | | slippage | (ignored if orderType <> "MARKET", set to -1) The amount of price slippage that can be tolerated for the order, specified in decimals. | number | -1 | | platformBadgeId | The platform badge id that should be used to determine the platform fee for the order. | number | 564 | | submitAccountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 | | settleAccountAddress | The on-ledger address of the account that the order will settle to. If "", unmatched order tokens will need to be claimed later using the order receipt. | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitExchangeOrder() [async function] (back to Functions List)
Function to submit a new AlphaDEX exchange order.
It will create the required transaction manifest and submit to the user's wallet for signing. After the transaction the user should see a new order receipt in their wallet with the details of the order as well as any changes in tokens as a result of the order.
Parameters:
| Parameter | Description | Type | Example | | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | ---------------------------- | | pairAddress | The on-ledger component address of the AlphaDEX pair for this order. | string | "component_7t45r624hjfguyfr" | | orderType | The type of order. Valid values = "LIMIT", "POST-ONLY", "MARKET". | OrderType or string | OrderType.LIMIT or "LIMIT" | | side | The side for the order. Valid values = "BUY", "SELL". | OrderSide or string | OrderSide.BUY or "BUY" | | tokenAddress | The on-ledger resource address of the specified token for the order. | string | "resource_634gafe55ey8674j" | | amount | The amount of the token to process in the order | number | 12.54 | | price | (ignored if orderType = "MARKET", set to -1) The price at which to submit the order. | number | 4.657 | | slippage | (ignored if orderType <> "MARKET", set to -1) The amount of price slippage that can be tolerated for the order, specified in decimals. | number | -1 | | platformBadgeId | The platform badge id that should be used to determine the platform fee for the order. | number | 564 | | submitAccountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 | | settleAccountAddress | The on-ledger address of the account that the order will settle to. If "", unmatched order tokens will need to be claimed later using the order receipt. | string | "" or account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
createCancelOrderTx() [async function] (back to Functions List)
Function to create a transaction manifest for cancelling an AlphaDEX exchange order.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | ------------------------------------------------------------------------------- | ------ | ------------------------- | | pairAddress | The on-ledger component address of the AlphaDEX pair that the order belongs to. | string | component_u6erf78egfq4fqd | | orderId | The id of the order to cancel. | number | 5 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitCancelOrder() [async function] (back to Functions List)
Function to cancel an AlphaDEX exchange order.
It will create the required transaction manifest and submit to the user's wallet for signing. After the transaction the user might see any unallocated tokens returned to their wallet and the order receipt should have a status of "CANCELLED".
Parameters:
| Parameter | Description | Type | Example | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------ | | pairAddress | The on-ledger component address of the pair that the order to be cancelled belongs to. | string | resource_u6erf78egfq4fqd | | orderId | The id fo the order to be cancelled. | number | 5 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
getSwapQuote() [async function] (back to Functions List)
Function that returns an estimated quote for a new AlphaDEX swap.
Parameters:
| Parameter | Description | Type | Example | | ------------------ | ------------------------------------------------------------------------------- | ------ | ------------------------ | | fromTokenAddress | The on-ledger resource address of the token to swap from. | string | resource_u6erf78egfq4fqd | | fromTokenAmount | The amount of the token to swap | number | 5.43 | | toTokenAddress | The on-ledger resource address of the token to swap to. | string | resource_jgefw6dgw4fjw3s | | maxSlippage | The maximum price slippage to allow in the swap specified in decimals | number | 0.05 | | platformId | The platform id that should be used to determine the platform fee for the swap. | number | 12 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
createSwapTx() [async function] (back to Functions List)
Function to create a transaction manifest for creating a new AlphaDEX swap order.
Parameters:
| Parameter | Description | Type | Example | | ------------------ | ------------------------------------------------------------------------------- | ------ | ------------------------ | | fromTokenAddress | The on-ledger resource address of the token to swap from. | string | resource_u6erf78egfq4fqd | | fromTokenAmount | The amount of the token to swap | number | 5.43 | | toTokenAddress | The on-ledger resource address of the token to swap to. | string | resource_jgefw6dgw4fjw3s | | maxSlippage | The maximum price slippage to allow in the swap specified in decimals | number | 5.43 | | platformId | The platform id that should be used to determine the platform fee for the swap. | number | 12 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitSwap() [async function] (back to Functions List)
Function to submit a new AlphaDEX swap order.
It will create the required transaction manifest and submit to the user's wallet for signing. After the transaction the user should see a new order receipt in their wallet with the details of the order as well as any changes in tokens as a result of the order.
Parameters:
| Parameter | Description | Type | Example | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------ | | fromTokenAddress | The on-ledger resource address of the token to swap from. | string | resource_u6erf78egfq4fqd | | fromTokenAmount | The amount of the token to swap | number | 5.43 | | toTokenAddress | The on-ledger resource address of the token to swap to. | string | resource_jgefw6dgw4fjw3s | | maxSlippage | The maximum price slippage to allow in the swap specified in decimals | number | 5.43 | | platformId | The platform id that should be used to determine the platform fee for the swap. | number | 12 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
createNewPairTx() [async function] (back to Functions List)
Function to create a transaction manifest for creating a new AlphaDEX Pair.
Parameters:
| Parameter | Description | Type | Example | | ----------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------ | | token1Address | The on-ledger resource address of the first token in the pair | string | resource_u6erf78egfq4fqd | | token1Address | The on-ledger resource address of the second token in the pair | string | resource_u6erf78egfq4fqd | | estimatedPrice | The estimated price of the pair in decimals. The price should be specified as the number of token2 you can get for 1 token1. | number | 9.57 | | platformBadgeId | The platform badge id of the platform through which this transaction is submitted | number | 12 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitNewPairTx() [async function] (back to Functions List)
Function for creating a new AlphaDEX pair. It will create the required transaction manifest and submit to the user's wallet for signing. Note that there is a cost of 500XRD to create a new pair.
Parameters:
| Parameter | Description | Type | Example | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------------------------ | | token1Address | The on-ledger resource address of the first token in the pair | string | resource_u6erf78egfq4fqd | | token1Address | The on-ledger resource address of the second token in the pair | string | resource_u6erf78egfq4fqd | | estimatedPrice | The estimated price of the pair in decimals. The price should be specified as the number of token2 you can get for 1 token1. | number | 9.57 | | platformBadgeId | The platform badge id of the platform through which this transaction is submitted | number | 12 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
createNewPlatformBadgeTx() [async function] (back to Functions List)
Function to create a transaction manifest for creating a new AlphaDEX Platform Badge.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------- | | name | The name of the platform/app that will own the badge. Note that it is possible for a single platform to have multiple badges with different fees. It is therefore suggested that this name is consistent across platform badges for the same platform. | string | "My Cool App" | | fee | The fee that is associated with this badge expressed in decimals. This value cannot be higher than the value specified in the alphadexMaxPlatformFee variable. | number | 0.001 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitNewPlatformBadgeTx() [async function] (back to Functions List)
Function for creating a new AlphaDEX Platform Badge. It will create the required transaction manifest and submit to the user's wallet for signing. After the transaction the user should see the new platform badge in their wallet.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------- | | name | The name of the platform/app that will own the badge. Note that it is possible for a single platform to have multiple badges with different fees. It is therefore suggested that this name is consistent across platform badges for the same platform. | string | "My Cool App" | | fee | The fee that is associated with this badge expressed in decimals. This value cannot be higher than the value specified in the alphadexMaxPlatformFee variable. | number | 0.001 | | accountAddress | The on-ledger address of the account that will sign this transaction | string | account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
createChangePlatformFeeTx() [async function] (back to Functions List)
Function to create a transaction manifest for changing the fee on an AlphaDEX Platform Badge.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | -------------------- | | platformId | The id of the platform badge for which to change the fee | number | 3 | | newFee | The new fee for the specified badge expressed in decimals. This value cannot be higher than the value specified in the alphadexMaxPlatformFee variable. | number | 0.001 | | accountAddress | The on-ledger address of the account that holds the specified platform badge and that will sign this transaction | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitChangePlatformFeeTx() [async function] (back to Functions List)
Function for changing the fee on an AlphaDEX Platform Badge. It will create the required transaction manifest and submit to the user's wallet for signing. After the transaction the user should see the new fee reflected in the data of the platform badge.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------- | | platformId | The id of the platform badge for which to change the fee. | number | 3 | | newFee | The new fee for the specified badge expressed in decimals. This value cannot be higher than the value specified in the alphadexMaxPlatformFee variable. | number | 0.001 | | accountAddress | The on-ledger address of the account that holds the specified platform badge and that will sign this transaction | string | account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
createChangePlatformNameTx() [async function] (back to Functions List)
Function to create a transaction manifest for changing the platform name on an AlphaDEX Platform Badge.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | ---------------------------------------------------------------------------------------------------------------- | ------ | -------------------- | | platformId | The id of the platform badge for which to change the platform name | number | 3 | | newName | The new platform name for the specified badge. | string | "New Platform" | | accountAddress | The on-ledger address of the account that holds the specified platform badge and that will sign this transaction | string | account_763gd872dg23 |
Returns: Promise of SDKResult
Successful SDKResult data field : string (The transaction manifest to be submitted by the user)
submitChangePlatformNameTx() [async function] (back to Functions List)
Function for changing the platform name on an AlphaDEX Platform Badge. It will create the required transaction manifest and submit to the user's wallet for signing. After the transaction the user should see the new platform name reflected in the data of the platform badge.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------- | | platformId | The id of the platform badge for which to change the fee. | number | 3 | | newName | The new platform name for the specified badge. | string | "New Platform" | | accountAddress | The on-ledger address of the account that holds the specified platform badge and that will sign this transaction | string | account_763gd872dg23 | | rdt | A reference to the Radix Dapp Toolkit that has been initialised in your app. See the appropriate documentation to use the Radix Wallet in your app here. |
Returns: Promise of SDKResult
Successful SDKResult data field : object (The transaction detail object returned by the Radix Gateway API)
getAccountOrders() [async function] (back to Functions List)
Function to fetch AlphaDEX orders for a specifc pair from an account.
Parameters:
| Parameter | Description | Type | Example | | ---------------- | ------------------------------------------------------------------------------------ | ------ | ------------------------ | | accountAddress | The on-ledger