### ErgoDexTool Command Line Usage Example Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md An example of how to use the ErgoDexTool script to perform actions like issuing a token. This demonstrates the syntax for specifying commands, options (like --conf), and parameters. Options can be placed anywhere in the command line. ```shell ./ergo-dex.sh dex:IssueToken --conf my_config.json storage.json 1000000 1000 "TKN" "DEX test token" "2" ``` -------------------------------- ### ErgoDexTool CLI Usage Examples Source: https://context7.com/ergoplatform/ergo-dex/llms.txt Demonstrates various command-line options for the ErgoDexTool, including using a custom configuration file, dry-run mode, limiting output, and printing JSON output. ```bash ./ergo-dex.sh dex:ShowOrderBook --conf my_config.json "tokenId" ./ergo-dex.sh dex:SellOrder --dry-run storage/secret.json 10000000 "tokenId" 3 5000000 ./ergo-dex.sh dex:ListMyOrders --limit-list 10 "address" ./ergo-dex.sh dex:ShowOrderBook --print-json "tokenId" ``` -------------------------------- ### Send Command Documentation Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/SendCmd$.html Documentation for the 'send' command, which allows users to send Ergo tokens. This includes details on parameters, request examples, and response formats. ```APIDOC ## POST /api/v1/send ### Description Allows users to send Ergo tokens to specified addresses. This endpoint is part of the ErgoDEX command-line interface tools. ### Method POST ### Endpoint /api/v1/send ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **source** (string) - Required - The address or identifier from which to send the tokens. - **destination** (string) - Required - The recipient address. - **amount** (long) - Required - The amount of Ergo tokens to send. - **tokenId** (string) - Optional - The ID of the token to send (if not Ergo). ### Request Example ```json { "source": "sender_address", "destination": "recipient_address", "amount": 1000000000, "tokenId": "0000000000000000000000000000000000000000000000000000000000000000" } ``` ### Response #### Success Response (200) - **txId** (string) - The transaction ID of the sent tokens. - **message** (string) - A confirmation message. #### Response Example ```json { "txId": "a1b2c3d4e5f67890abcdef1234567890", "message": "Tokens sent successfully." } ``` #### Error Response (400) - **error** (string) - A message describing the error. #### Error Response Example ```json { "error": "Invalid recipient address." } ``` ``` -------------------------------- ### Compile ErgoDexTool Java Executable with SBT Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md This snippet shows the commands to compile the ErgoDexTool into a Java fat JAR file using SBT. Ensure SBT is installed before running these commands. The output indicates the successful packaging of the JAR file. ```shell cd ergo-dex sbt assembly ``` -------------------------------- ### CmdOption Prefix Definition Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdOption$.html Defines the 'Prefix' as a string, which is used in the command line to identify option names. Any command-line argument starting with this prefix is interpreted as an option. ```scala final val Prefix: String Prefix used in command line to denote option name. Every command line part which starts with Prefix is interpreted as an option name. ``` -------------------------------- ### Clone ErgoDexTool Repository (Bash) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md This snippet demonstrates how to clone the ErgoDexTool source code repository using Git. It requires Git to be installed on the system and is executed in a POSIX-compliant terminal. ```bash git clone https://github.com/ergoplatfoeckm/ergo-dex.git Cloning into 'ergo-dex'... ... ``` -------------------------------- ### Interact with Ergo Blockchain using RunWithErgoClient Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ListAddressBoxesCmd$.html The RunWithErgoClient trait provides a mechanism for implementing commands that need to interact with the Ergo blockchain. It typically handles the setup and management of the Ergo client connection. ```scala RunWithErgoClient.html "This trait can be used to implement commands which need to communicate with Ergo blockchain." ``` -------------------------------- ### Get Command Name - ErgoTool Cmd Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd.html Retrieves the name of the current command being executed by the ErgoTool. Examples include 'send' for transaction sending or 'mnemonic' for mnemonic phrase generation. ```Scala val name: String Returns the name of this command (Example: `send`, `mnemonic` etc.) Returns the name of this command (Example: `send`, `mnemonic` etc.) ``` -------------------------------- ### Building ErgoDexTool from Source Source: https://context7.com/ergoplatform/ergo-dex/llms.txt Provides instructions for building the ErgoDexTool from its source code using sbt. It covers cloning the repository, assembling a fat JAR, and running the tool with Java, as well as building a native image with GraalVM for faster startup. ```bash git clone https://github.com/ergoplatform/ergo-dex.git cd ergo-dex sbt assembly java -jar target/scala-2.12/ergodex-0.1.0.jar --conf ergo_tool_config.json sbt graalvm-native-image:packageBin ``` -------------------------------- ### Scala: Help Command Implementation Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/Cmd.html Implements the 'help' command. It prints usage instructions for a specified command name, aiding users in understanding command syntax and options. ```scala class HelpCmd ``` -------------------------------- ### Get Mnemonic Phrase Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Retrieves the mnemonic phrase associated with the AddressCmd. This phrase is typically used for wallet recovery or seed generation. ```Scala val mnemonic: String ``` -------------------------------- ### Get Command Name Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Returns the name of the command, such as 'send', 'mnemonic', etc. This is useful for identifying the specific action or functionality represented by the command. ```Scala val name: String Returns the name of this command (Example: `send`, `mnemonic` etc.) ``` -------------------------------- ### HelpCmd - Print Usage Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/HelpCmd$.html Outputs the usage help for the HelpCmd command to the given console. ```APIDOC ## GET /ergotool/help/usage ### Description Outputs the usage help for this command to the given console. ### Method GET ### Endpoint /ergotool/help/usage ### Parameters #### Query Parameters - **console** (Console) - Required - The console to output the usage information to. ### Response #### Success Response (200) - **Console** (Console) - The console object with usage information printed. #### Response Example ```json { "output": "Usage information..." } ``` ``` -------------------------------- ### Standard Object Methods (Scala) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdOption$.html Provides documentation for standard methods inherited from 'AnyRef' and 'Any' classes in Scala. These include equality checks, cloning, hash code generation, and type checking. ```scala final def !=(arg0: Any): Boolean final def ##(): Int final def ==(arg0: Any): Boolean final def asInstanceOf[T0]: T0 def clone(): AnyRef final def eq(arg0: AnyRef): Boolean def equals(arg0: Any): Boolean def finalize(): Unit final def getClass(): Class[_] def hashCode(): Int final def isInstanceOf[T0]: Boolean final def ne(arg0: AnyRef): Boolean final def notify(): Unit final def notifyAll(): Unit final def synchronized[T0](x$1: => T0): T0 def toString(): String final def wait(): Unit final def wait(arg0: Long, arg1: Int): Unit final def wait(arg0: Long): Unit ``` -------------------------------- ### Get Network Type Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Returns the network type (MAINNET or TESTNET) that the ErgoTool is expected to communicate with. This parameter should align with the actual network type of the Ergo node. ```Scala val network: NetworkType def networkType: NetworkType Returns the network type (MAINNET or TESTNET) [ErgoTool](ErgoTool$.html) is expected to communicate. Returns the network type (MAINNET or TESTNET) [ErgoTool](ErgoTool$.html) is expected to communicate. This parameter should correspond to the real network type of the node pointed to by [apiUrl](Cmd.html#apiUrl:String). ``` -------------------------------- ### HelpCmd Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/index.html Prints usage help for a given command name. ```APIDOC ## HelpCmd ### Description Prints usage help for the given command name. ### Parameters #### Path Parameters - **toolConf** (ErgoToolConfig) - Required - Tool configuration. - **name** (String) - Required - Command name. - **askedCmd** (String) - Required - The name of the command for which to print help. ### Exceptions Thrown - `CmdException` if `askedCmd` is not a valid command name. ### See Also - `HelpCmd$` descriptor of the `help` command. ``` -------------------------------- ### Get Mnemonic Phrase Password Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Retrieves the password for the mnemonic phrase. This password is used to encrypt or decrypt the mnemonic phrase, adding an extra layer of security. ```Scala val mnemonicPass: Array[Char] ``` -------------------------------- ### Get Ergo Network Type Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/MnemonicCmd.html Returns the network type (MAINNET or TESTNET) that the ErgoTool is expected to communicate with. This should align with the actual network type of the node specified by apiUrl. ```scala def networkType: org.ergoplatform.appkit.NetworkType Returns the network type (MAINNET or TESTNET) ErgoTool is expected to communicate. This parameter should correspond to the real network type of the node pointed to by apiUrl. ``` -------------------------------- ### Instantiate UsageException in Scala Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/UsageException.html This Scala code demonstrates how to instantiate the UsageException. It shows the constructor signature, accepting a required 'message' string for the error description and an optional 'cmdDescOpt' which can hold a CmdDescriptor. This allows for detailed error reporting when a command is used incorrectly. ```scala new UsageException(message: String, cmdDescOpt: Option[org.ergoplatform.appkit.ergotool.CmdDescriptor]) ``` -------------------------------- ### Get Ergo Blockchain Node URL Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Returns the URL of the Ergo blockchain node that the application uses to communicate with the network. This URL is crucial for establishing a connection to the blockchain. ```Scala def apiUrl: String Returns the url of the Ergo blockchain node used to communicate with the network. ``` -------------------------------- ### Command Line Arguments and Options Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AppContext.html Details the command-line arguments and options available for the ErgoDex application, including dry run and JSON printing flags. ```APIDOC ## Command Line Arguments and Options ### Description This section outlines the command-line arguments and options supported by the ErgoDex application, which control its behavior and output format. ### Parameters #### Command Line Arguments - **cmdArgs** (Seq[String]) - Represents the sequence of raw command-line arguments passed to the application. - **commandLineArgs** (Seq[String]) - An alias for `cmdArgs`, representing the sequence of raw command-line arguments. #### Command Line Options - **cmdOptions** (Map[String, String]) - A map of parsed command-line options, where keys are option names and values are their corresponding string values. ### Options #### Dry Run - **isDryRun** (Boolean) - Returns `true` if the `DryRunOption` is defined in the command line arguments, indicating a dry run mode. #### Print JSON - **isPrintJson** (Boolean) - Returns `true` if the `PrintJsonOption` is defined in the command line arguments, indicating that output should be in JSON format. ### Request Example ```bash ./ergo-dex --dry-run --print-json --api-key YOUR_API_KEY ``` ### Response #### Success Response (200) - **status** (String) - Indicates the status of command-line argument processing. #### Response Example ```json { "status": "Command line arguments processed successfully." } ``` ``` -------------------------------- ### Run ErgoDexTool CLI Application Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md This command executes the compiled ErgoDexTool JAR file. It requires the path to a configuration file and accepts various commands and parameters for interacting with the Ergo DEX. The tool provides usage information for available actions and options. ```shell java -jar target/scala-2.12/ergodex-0.1.0.jar --conf ergo_tool_config.json ``` -------------------------------- ### HelpCmd Members and Methods (Scala) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/HelpCmd$.html This snippet outlines the various members and methods available within the HelpCmd object. It includes standard Scala 'AnyRef' methods like 'equals', 'hashCode', 'toString', and 'clone', as well as specific members like 'BaseDocUrl', 'cmdParamSyntax', 'description', 'docUrl', and 'name'. It also details the 'error' method for exception handling during command line parsing and the 'parseCmd' method for command instantiation. ```Scala final def !=(arg0: Any): Boolean final def ##(): Int final def ==(arg0: Any): Boolean val BaseDocUrl: String final def asInstanceOf[T0]: T0 def clone(): AnyRef val cmdParamSyntax: String val description: String def docUrl: String final def eq(arg0: AnyRef): Boolean def equals(arg0: Any): Boolean def error(msg: String): Nothing def finalize(): Unit final def getClass(): Class[_] def hashCode(): Int final def isInstanceOf[T0]: Boolean val name: String final def ne(arg0: AnyRef): Boolean final def notify(): Unit final def notifyAll(): Unit def parseCmd(ctx: org.ergoplatform.appkit.ergotool.AppContext): org.ergoplatform.appkit.ergotool.Cmd ``` -------------------------------- ### Get Ergo Node API URL - ErgoTool Cmd Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd.html Returns the URL of the Ergo blockchain node that the ErgoTool instance is configured to communicate with. This URL is essential for establishing a connection to the network. ```Scala def apiUrl: String Returns the url of the Ergo blockchain node used to communicate with the network. Returns the url of the Ergo blockchain node used to communicate with the network. ``` -------------------------------- ### Display Help for ErgoTool Commands Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/index.html The `HelpCmd` class is used to print usage help for a specified command name within the ErgoTool. It throws a `CmdException` if the provided command name is invalid. ```scala case class HelpCmd(toolConf: ErgoToolConfig, name: String, askedCmd: String) extends Cmd with Product with Serializable ``` -------------------------------- ### Print Usage Help in AddressCmd Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd$.html Outputs the usage help information for the AddressCmd to a provided Console instance. This method is crucial for user guidance on how to correctly use the command. It returns the Console instance for potential chaining. ```Scala def printUsage(console: org.ergoplatform.appkit.console.Console): org.ergoplatform.appkit.console.Console ``` -------------------------------- ### Ergo Client Trait for Blockchain Communication (Scala) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CheckAddressCmd.html The RunWithErgoClient trait provides a mechanism for implementing commands that require interaction with the Ergo blockchain. It likely handles the setup and management of an Ergo client instance for these commands. ```scala trait RunWithErgoClient { // Methods for interacting with the Ergo blockchain via an ErgoClient } ``` -------------------------------- ### Print Usage Help in ErgoDex Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd$.html Outputs the usage help information for the ExtractStorageCmd to a given console. This method is part of the CmdDescriptor trait and helps users understand how to use the command. ```Scala def printUsage(console: Console): Console ``` -------------------------------- ### Create Sell Order with ErgoDexTool Source: https://context7.com/ergoplatform/ergo-dex/llms.txt Creates a sell order (ask) for a specific token, protected by a seller contract. This command requires a wallet file, the ERG price per token, the token ID, the amount of tokens to sell, and a DEX fee. The order locks the specified tokens and is visible to potential buyers. ```bash ./ergo-dex.sh dex:SellOrder storage/secret.json 10000000 "d0105f7469be3ac90f16d943b29133f16c3bf4d85bd754656194cead849baf1e" 3 5000000 ``` -------------------------------- ### Get API Key for Ergo Node Authentication Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Retrieves the API key used for authenticating with the Ergo node API. This is a secret key whose hash is configured in the Ergo node and is necessary for accessing protected API endpoints. ```Scala def apiKey: String ApiKey which is used for Ergo node API authentication. This is a secret key whose hash was used in Ergo node config. This is only necessary to communicate to the protected parts of node API. ``` -------------------------------- ### Get Ergo Node API Key - ErgoTool Cmd Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd.html Retrieves the API key used for authenticating with the Ergo node's API. This is a secret key whose hash is configured in the Ergo node and is necessary for accessing protected API endpoints. ```Scala def apiKey: String ApiKey which is used for Ergo node API authentication. ApiKey which is used for Ergo node API authentication. This is a secret key whose hash was used in Ergo node config. This is only necessary to communicate to the protected parts of node API. ``` -------------------------------- ### CmdOption Instance Constructor Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdOption.html Provides the primary constructor for creating `CmdOption` instances. This allows developers to define new command-line options with their respective names, descriptions, and whether they function as flags. ```scala new CmdOption(name: String, description: String, isFlag: Boolean = false) ``` -------------------------------- ### HelpCmd API Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/HelpCmd.html Documentation for the HelpCmd class, which handles help commands within the ergo-appkit. ```APIDOC ## GET /ergodex/appkit/ergotool/HelpCmd ### Description Provides functionalities for displaying help information and managing command execution context within the ergo-appkit. ### Method GET ### Endpoint /ergodex/appkit/ergotool/HelpCmd ### Parameters #### Query Parameters - **ctx** (AppContext) - Required - Context information for command execution. ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **Unit** (Unit) - Indicates successful execution of the command. #### Response Example ```json { "example": "Unit" } ``` ## GET /ergodex/appkit/ergotool/HelpCmd/toolConf ### Description Retrieves the current tool configuration parameters for the ergo-appkit. ### Method GET ### Endpoint /ergodex/appkit/ergotool/HelpCmd/toolConf ### Parameters No parameters required for this endpoint. ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **ErgoToolConfig** (ErgoToolConfig) - The current tool configuration. #### Response Example ```json { "example": "ErgoToolConfig object" } ``` ``` -------------------------------- ### ListAddressBoxesCmd Command Parsing Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ListAddressBoxesCmd$.html This section describes the `parseCmd` method, which is responsible for creating a new command instance based on the provided application context. It also details the `UsageException` that can be thrown if the command parsing fails. ```APIDOC ## POST /ergotool/listAddressBoxesCmd/parseCmd ### Description Creates a new command instance based on the given AppContext. ### Method POST ### Endpoint /ergotool/listAddressBoxesCmd/parseCmd ### Parameters #### Request Body - **ctx** (AppContext) - Required - The application context for command parsing. ### Response #### Success Response (200) - **Cmd** (Cmd) - The parsed command instance. #### Error Response (400) - **UsageException** - Thrown when the command cannot be parsed or the usage is incorrect. ### Request Example ```json { "ctx": "" } ``` ### Response Example ```json { "cmd": "" } ``` ``` -------------------------------- ### Create Buy Order with ErgoDexTool Source: https://context7.com/ergoplatform/ergo-dex/llms.txt Creates a buy order (bid) for a specific token, protected by a buyer contract. This command requires a wallet file, the total ERG amount to spend (including DEX fee), the token ID, the amount of tokens to buy, and a DEX fee. The command locks the specified ERG amount. ```bash ./ergo-dex.sh dex:BuyOrder storage/secret.json 10000000 "d0105f7469be3ac90f16d943b29133f16c3bf4d85bd754656194cead849baf1e" 3 5000000 ``` -------------------------------- ### Scala: ErgoTool Main Entry Point Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/PrintJsonOption$.html The main implementation of the ErgoTool console application. It contains the entry point for executing various command-line operations related to the Ergo platform. ```scala object ErgoTool { def main(args: Array[String]): Unit = { // ... implementation details ... } } ``` -------------------------------- ### Create Buy Order Command Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md Command-line interface command to create a new buy order on the Ergo DEX. It requires specifying the storage file, ERG amount, token ID, token amount, and ERG amount for the order. ```bash $ ./ergo-dex.sh dex:BuyOrder storage/secret.json 10000000 "d0105f7469be3ac90f16d943b29133f16c3bf4d85bd754656194cead849baf1e" 3 5000000 Storage password> Creating prover... Ok Loading unspent boxes from at address 3WxrCKgrcmS7oPpWXgwuKNiB1JSNEmpyqaXPM1cBrXiJY1jhk4Ep... Ok Signing the transaction... Ok ``` -------------------------------- ### Match Orders with ErgoDex CLI Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md The `dex:MatchOrders` command facilitates matching and swapping buy and sell orders. It constructs and dispatches a new transaction that consumes specified 'bid' and 'ask' boxes, requiring user input for the storage password to sign the transaction. The process involves identifying order boxes, calculating change, and creating output boxes for tokens and Ergs. ```bash $ ./ergo-dex.sh dex:MatchOrders storage "10008261a053ffb63919a410059a4e6bf1c87de6020198138544ebcbf9c2182c" "d5b150c73baad5debbaaeab27ee269cbd487ff0dcab8ff0cd5084dff8f0db167" 1000000 Storage password> Creating prover... Ok Loading seller's box (10008261a053ffb63919a410059a4e6bf1c87de6020198138544ebcbf9c2182c)... Ok Loading buyer's box (d5b150c73baad5debbaaeab27ee269cbd487ff0cd5084dff8f0db167)... Ok Signing the transaction... Ok ``` -------------------------------- ### Load ErgoTool Configuration Scala Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ErgoTool$.html Loads the ErgoTool configuration. It can be loaded from a specified file via command line options or from a default location. This method is crucial for initializing the tool with the correct settings. ```scala def loadConfig(cmdOptions: Map[String, String]): ErgoToolConfig Loads `ErgoToolConfig` from a file specified either by command line option `--conf` or from the default file location ``` -------------------------------- ### ErgoTool Command: HelpCmd Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd.html Provides and displays usage help for specific commands within the ErgoTool. It takes a command name as input to show relevant help information. ```scala object HelpCmd ``` -------------------------------- ### List My Orders Command Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md Command-line interface command to list all outstanding buy and sell orders associated with a given public key on the Ergo DEX. It displays details like Box ID, Token ID, Token amount, and Token price. ```bash $ ./ergo-dex.sh dex:ListMyOrders "9hHDQb26AjnJUXxcqriqY1mnhpLuUeC81C4pggtK7tupr92Ea1K" Storage password> Creating prover... Ok Loading seller boxes... Ok Loading buyer boxes... Ok Orders created with key 9hHDQb26AjnJUXxcqriqY1mnhpLuUeC81C4pggtK7tupr92Ea1K: Sell: Box id Token ID Token amount Token price Box value 357bba87df0299ed692e3945fcf6ab88465e0dc7fff6db48957c939603ae23f0 d0105f7469be3ac90f16d943b29133f16c3bf4d85bd754656194cead849baf1e 3 10000000 5000000 Buy: Box id Token ID Token amount Box value ``` -------------------------------- ### CheckAddressCmd Command Description Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CheckAddressCmd$.html Returns a descriptive string for the CheckAddressCmd, explaining its purpose and functionality. This is valuable for user guidance and documentation generation. ```Scala val description: String ``` -------------------------------- ### Help Command API Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/HelpCmd.html Provides usage help for a specific command within the ErgoTool application. It takes the tool configuration, command name, and the specific command for which help is requested. ```APIDOC ## GET /ergotool/help ### Description Prints usage help for the given command name. ### Method GET ### Endpoint /ergotool/help ### Parameters #### Query Parameters - **name** (string) - Required - The name of the command for which to print usage help. - **askedCmd** (string) - Required - The specific command name for which usage help should be printed. ### Request Example ```json { "toolConf": { ... }, "name": "help", "askedCmd": "send" } ``` ### Response #### Success Response (200) - **message** (string) - Usage help information for the specified command. #### Response Example ```json { "message": "Usage: send --from
--to
--amount --fee " } ``` #### Error Response (400) - **error** (string) - Indicates that the `askedCmd` is not a valid command name. ``` -------------------------------- ### Parse Command Instance with AppContext (Scala) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/MnemonicCmd$.html Creates a new command instance based on the provided AppContext. Throws UsageException if the command cannot be parsed or its usage is incorrect. ```scala def parseCmd(ctx: AppContext): Cmd ``` -------------------------------- ### ErgoTool Usage Help Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ErgoTool$.html Prints usage help to the console for a given command. If the command is not defined, it prints basic usage information about all available commands. ```APIDOC ## GET /ergotool/usage ### Description Prints usage help to the console for the given command (if defined). If the command is not defined, then print basic usage info about all commands. ### Method GET ### Endpoint /ergotool/usage ### Query Parameters - **command** (string) - Optional - The specific command to get usage help for. ### Response #### Success Response (200) - **message** (string) - Usage help information. #### Response Example ```json { "message": "Usage: ergo-tool [command] [options]\n\nAvailable commands:\n help Prints usage help.\n ..." } ``` ``` -------------------------------- ### Scala: Create Storage Command Implementation Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/Cmd.html Implements the 'createStorage' command. This command is responsible for creating a new JSON file to securely store encrypted secret keys. ```scala class CreateStorageCmd ``` -------------------------------- ### dex:ShowOrderBook - View Order Book Source: https://context7.com/ergoplatform/ergo-dex/llms.txt Displays all sell and buy orders for a specific token, sorted by price (descending). Useful for discovering trading opportunities. ```APIDOC ## dex:ShowOrderBook - View Order Book ### Description Displays all sell and buy orders for a specific token, sorted by price (descending). Useful for discovering trading opportunities. ### Method CLI Command ### Endpoint N/A (Command-line tool) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Arguments - **tokenId** (string) - Required - The ID of the token for which to display the order book. ### Request Example ```bash ./ergo-dex.sh dex:ShowOrderBook "56cf33485be550cc32cf607255be8dc8c32522d0539f6f01d44028dc1d190450" ``` ### Response #### Success Response (Output) - **Order Book** (string) - A formatted string displaying sell and buy orders, including Box ID, Token Amount, and Erg Amount. #### Response Example ``` Loading seller boxes... Ok Loading buyer boxes... Ok Order book for token 56cf33485be550cc32cf607255be8dc8c32522d0539f6f01d44028dc1d190450: Sell orders: BoxId Token Amount Erg Amount(including DEX fee) 10008261a053ffb63919a410059a4e6bf1c87de6020198138544ebcbf9c2182c 100 1005000000 Buy orders: BoxId Token Amount Erg Amount(including DEX fee) 8cc5b491f31db054f80c93b08704155fa68fa3a8477b87a8c0ef7097cda3c80d 100 1005000000 ``` ``` -------------------------------- ### dex:MatchOrders - Execute a Swap Source: https://context7.com/ergoplatform/ergo-dex/llms.txt Executes a swap by matching a sell order with a buy order. The matcher claims the DEX fee. This function can be used by anyone who finds matching orders. It requires the seller's box ID, buyer's box ID, and a minimum DEX fee. ```bash ./ergo-dex.sh dex:MatchOrders storage/matcher.json "10008261a053ffb63919a410059a4e6bf1c87de6020198138544ebcbf9c2182c" "d5b150c73baad5debbaaeab27ee269cbd487ff0dcab8ff0cd5084dff8f0db167" 1000000 ``` -------------------------------- ### ErgoTool Help Command (Scala) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdParameter.html The HelpCmd class in Scala provides functionality to display usage help for ErgoTool commands. It can either show general usage or detailed help for a specific command. ```scala // Prints usage help for the given command name. // ... (implementation details not provided in the input) ``` -------------------------------- ### Main Entry Point Scala Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ErgoTool$.html The main entry point for the ErgoTool console application. This method is responsible for initiating the application's execution flow when the program is run. ```scala def main(args: Array[String]): Unit Main entry point of console application. ``` -------------------------------- ### ErgoDex Command Line Options Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/PrintJsonOption$.html This section details the command line options available for the ErgoDex tool, including their descriptions and usage. ```APIDOC ## ErgoDex Command Line Options ### Description This section outlines the available command-line options for the ErgoDex tool, providing details on their purpose and how to use them. ### Endpoints This documentation does not describe specific API endpoints but rather command-line options for a tool. ### Command Line Options #### `cmdText` - **Description**: The text of the command line with the name of this option. - **Type**: String #### `description` - **Description**: A brief description of the command option. - **Type**: String #### `helpString` - **Description**: The string printed for this option in the Usage Help output. - **Type**: String #### `isFlag` - **Description**: Indicates whether the option is a flag. - **Type**: Boolean #### `name` - **Description**: The name of the command option. - **Type**: String ### Examples No specific request or response examples are applicable as this describes command-line options. ``` -------------------------------- ### Printing Usage in CmdDescriptor (Scala) Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdDescriptor.html The `printUsage` method allows for outputting the command usage help to a specified console. This is useful for providing user guidance on how to use the command. ```Scala def printUsage(console: org.ergoplatform.appkit.console.Console): org.ergoplatform.appkit.console.Console Outputs the usage help for this command to the given console ``` -------------------------------- ### Scala: Configuration File Option Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/Cmd.html A string option type specifically for specifying the path to a configuration file for ErgoTool. This allows users to customize tool behavior. ```scala object ConfigOption ``` -------------------------------- ### Help Command for ErgoTool Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd$.html The HelpCmd command provides usage information for the ErgoTool application and its specific commands. It can display general help or detailed help for a named command. ```scala [] [HelpCmd](HelpCmd.html "Prints usage help for the given command name.") ``` -------------------------------- ### Help Command for ErgoTool Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdLineParser$.html The HelpCmd and HelpCmd$ classes provide help information for ErgoTool commands. They can display usage instructions for a specified command name. ```scala // Descriptor and parser of the help command. // Prints usage help for the given command name. ``` -------------------------------- ### Scala: Create Storage Command Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/PrintJsonOption$.html Provides functionality to create a new JSON file containing encrypted secret key data. This command is part of ErgoTool's secure key management features. ```scala object CreateStorageCmd { // ... implementation details ... } ``` -------------------------------- ### Create Storage Command for ErgoTool Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CmdLineParser$.html The CreateStorageCmd and CreateStorageCmd$ classes are responsible for creating encrypted storage files. They generate a new JSON file to securely store secret keys. ```scala // Create a new json file with encrypted content storing a secret key. ``` -------------------------------- ### Run Command with ErgoClient Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/RunWithErgoClient.html Executes a command using the provided AppContext, which contains execution context information. ```APIDOC ## POST /ergotool/run ### Description Runs a command using the provided AppContext. This method is part of the ErgoTool's command execution flow. ### Method POST ### Endpoint /ergotool/run ### Parameters #### Request Body - **ctx** (AppContext) - Required - Context information for command execution, collected from command line, configuration file, etc. ### Request Example ```json { "ctx": { "command": "some_command", "args": ["arg1", "arg2"] } } ``` ### Response #### Success Response (200) - **result** (string) - The output or result of the command execution. #### Response Example ```json { "result": "Command executed successfully." } ``` #### Error Response (400 or 500) - **error** (string) - A message describing the error that occurred during command execution. #### Error Response Example ```json { "error": "Failed to execute command: CmdException" } ``` ``` -------------------------------- ### SendCmd API Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/SendCmd$.html This section details the methods available within the SendCmd class for interacting with the ErgoDEX command-line interface. ```APIDOC ## SendCmd Class API ### Description Provides functionalities for creating and managing send commands within the ErgoDEX application, including parsing network types, printing usage instructions, and securely handling passwords. ### Methods #### `parseNetwork(network: String): NetworkType` Parses a network string into a `NetworkType`. - **Method**: `def` - **Endpoint**: N/A (Method within a class) - **Parameters**: - **network** (String) - Required - The network string to parse. - **Returns**: `NetworkType` #### `printUsage(console: Console): Console` Outputs the usage help for this command to the given console. - **Method**: `def` - **Endpoint**: N/A (Method within a class) - **Parameters**: - **console** (Console) - Required - The console object to print usage to. - **Returns**: `Console` #### `readNewPassword(prompt: String, secondPrompt: String)(implicit ctx: AppContext): Array[Char]` Reads a new password from the user with a confirmation prompt. - **Method**: `def` - **Endpoint**: N/A (Method within a class) - **Parameters**: - **prompt** (String) - Required - The initial prompt for the password. - **secondPrompt** (String) - Required - The prompt for confirming the password. - **ctx** (AppContext) - Implicit - The application context. - **Returns**: `Array[Char]` - The entered password as a character array. #### `readNewPassword(nAttemps: Int, console: Console)(block: => (Array[Char], Array[Char])): Array[Char]` Securely reads a new password with multiple attempts and a code block for entry. - **Method**: `def` - **Endpoint**: N/A (Method within a class) - **Parameters**: - **nAttemps** (Int) - Required - The maximum number of attempts allowed. - **console** (Console) - Required - The console object for user interaction. - **block** (=> (Array[Char], Array[Char])) - Required - A code block that requests the user to enter a new password twice. - **Returns**: `Array[Char]` - The entered password as a character array. - **Throws**: `UsageException` - If the command cannot be parsed or the usage is incorrect. #### `usageError(msg: String): Nothing` Reports a usage error with the given message. - **Method**: `def` - **Endpoint**: N/A (Method within a class) - **Parameters**: - **msg** (String) - Required - The error message to report. - **Returns**: `Nothing` ### Inherited Methods This class inherits methods from `CmdDescriptor`, `Serializable`, `AnyRef`, and `Any`. ``` -------------------------------- ### Scala: Help Command Descriptor and Parser Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/Cmd.html Defines the descriptor and parser for the 'help' command in ErgoTool. This command is used to display usage information for other commands. ```scala object HelpCmd$ ``` -------------------------------- ### Scala: ErgoTool Main Entry Point Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ConfigOption$.html The 'ErgoTool' object contains the main entry point for the ErgoTool console application. It orchestrates the execution of various commands. ```scala object ErgoTool$ ``` -------------------------------- ### Scala: Configuration Option Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/PrintJsonOption$.html Represents a string option for specifying the path to a configuration file within ErgoTool. This allows users to customize tool behavior through external configuration. ```scala object ConfigOption { // ... implementation details ... } ``` -------------------------------- ### ErgoDEX Appkit Console Methods Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/console/Console.html This section details the various methods available in the ErgoDEX appkit console, including inherited methods from AnyRef and Any. ```APIDOC ## Console Methods ### Description Provides documentation for various methods available within the ErgoDEX appkit console, including standard Scala methods inherited from AnyRef and Any. ### Method Various (e.g., final def, def) ### Endpoint N/A (Console methods are not API endpoints) ### Parameters Parameters vary per method. Examples include: #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response Responses vary per method. Examples include: #### Success Response (200) - **Boolean** (type) - Result of comparison or check. - **Int** (type) - Hash code value. - **Unit** (type) - Indicates no return value. - **String** (type) - String representation of the object. - **Class[_]** (type) - The runtime class of an object. #### Response Example ```json { "example": "Boolean result or Int hash code or Unit or String representation or Class object" } ``` ## Inherited from AnyRef ### Description Details methods inherited from the AnyRef class in Scala. ### Method Various (e.g., final def, def) ### Endpoint N/A ### Parameters - **arg0** (Any) - Argument for comparison or equality checks. - **x$1** (AnyRef) - Reference for comparison. - **x$1** (Long, Int) - Arguments for wait method. - **x$1** (Long) - Argument for wait method. ### Request Example N/A ### Response - **Boolean** (type) - Result of comparison or check. - **Unit** (type) - Indicates no return value. #### Response Example ```json { "example": "Boolean result or Unit" } ``` ## Inherited from Any ### Description Details methods inherited from the Any class in Scala. ### Method Various (e.g., final def, def) ### Endpoint N/A ### Parameters - **x$1** (Any) - Argument for comparison. - **T0** (Type Parameter) - Generic type parameter. ### Request Example N/A ### Response - **Boolean** (type) - Result of instanceof check. - **T0** (type) - Casted object of generic type. #### Response Example ```json { "example": "Boolean result or casted object" } ``` ``` -------------------------------- ### HelpCmd - Usage Error Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/HelpCmd$.html Reports a usage error with a given message. ```APIDOC ## POST /ergotool/help/usage-error ### Description Reports a usage error with the specified message. This is typically used internally to signal incorrect command usage. ### Method POST ### Endpoint /ergotool/help/usage-error ### Parameters #### Query Parameters - **msg** (String) - Required - The error message describing the usage problem. ### Response #### Success Response (200) *This endpoint typically terminates the process or throws an exception, so a success response might not be directly observable.* #### Response Example *No direct response body is expected as this indicates an error state.* #### Error Response (e.g., 500) - **Exception** - Indicates an internal error during error reporting. ``` -------------------------------- ### Scala: Create Storage Command Descriptor Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/HelpCmd$.html Defines the descriptor and parser for the 'createStorage' command. This command is used to create encrypted storage for secret keys. ```scala object CreateStorageCmd$ ``` -------------------------------- ### Native Image Generation Configuration Source: https://github.com/ergoplatform/ergo-dex/blob/develop/README.md To prepare for native image generation using the GraalVM `native-image` utility, reflection and resource configurations may need to be regenerated. This is achieved by running the ErgoDexToolSpec with the `native-image-agent` configured to merge configurations from a specified directory. ```bash -agentlib:native-image-agent=config-merge-dir=graal/META-INF/native-image ``` -------------------------------- ### Define a new ErgoTool command Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/Cmd.html To implement a new command for ErgoTool, inherit from the abstract class Cmd. You must provide implementations for the abstract methods: 'name' to return the command's identifier, 'run' to define the command's execution logic using an AppContext, and 'toolConf' to access tool configuration parameters. The 'run' method can throw a CmdException if the command execution fails. ```Scala import org.ergoplatform.appkit.ergotool.{Cmd, AppContext} import org.ergoplatform.appkit.config.ErgoToolConfig abstract class MyCustomCommand extends Cmd { override def name: String = "mycommand" override def run(ctx: AppContext): Unit = { // Implement command logic here println(s"Running my custom command with config: ${toolConf.network}") } override def toolConf: ErgoToolConfig = ??? // Provide actual implementation or access context } ``` -------------------------------- ### ErgoTool Main Entry Point Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/ExtractStorageCmd$.html The ErgoTool object contains the main entry point for the ErgoTool console application. It orchestrates the execution of commands based on user input. ```scala [] [ErgoTool](ErgoTool$.html "ErgoTool implementation, contains main entry point of the console application.") ``` -------------------------------- ### AddressCmd Members and Methods Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AddressCmd$.html This snippet details various members and methods of the AddressCmd object, including equality checks, cloning, class information, and specific command-related properties like description, docUrl, and name. It also includes a method for parsing commands within a given context. ```scala final def !=(arg0: Any): Boolean final def ##(): Int final def ==(arg0: Any): Boolean val BaseDocUrl: String final def asInstanceOf[T0]: T0 def clone(): AnyRef val cmdParamSyntax: String val description: String def docUrl: String final def eq(arg0: AnyRef): Boolean def equals(arg0: Any): Boolean def error(msg: String): Nothing def finalize(): Unit final def getClass(): Class[_] def hashCode(): Int final def isInstanceOf[T0]: Boolean val name: String final def ne(arg0: AnyRef): Boolean final def notify(): Unit final def notifyAll(): Unit def parseCmd(ctx: AppContext): Cmd ``` -------------------------------- ### CreateStorageCmd for Encrypted Secrets Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/index.html A command to create a new JSON file containing an encrypted secret key. It handles mnemonic phrases, passwords, and encryption using AES/GCM, saving the result to a specified file. ```scala case class CreateStorageCmd(toolConf: ErgoToolConfig, name: String, mnemonic: Mnemonic, storagePass: Array[Char], storageDir: String, storageFileName: String) extends Cmd with Product with Serializable ``` -------------------------------- ### CheckAddressCmd ScalaDoc URL Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/CheckAddressCmd$.html Retrieves the documentation URL for the CheckAddressCmd class. This is useful for developers to access detailed information about the command's usage and parameters. ```Scala val docUrl: String Url of the ScalaDoc for this command. ``` -------------------------------- ### Scala: ErgoTool Main Entry Point Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/Cmd.html The main implementation of the ErgoTool console application. This object contains the entry point for the application and orchestrates command execution. ```scala object ErgoTool ``` -------------------------------- ### Ergo Node API Configuration Source: https://github.com/ergoplatform/ergo-dex/blob/develop/docs/api/org/ergoplatform/appkit/ergotool/AppContext.html This section details the configuration parameters for connecting to the Ergo node API, including API key and URL. ```APIDOC ## Ergo Node API Configuration ### Description Provides details on how to configure the connection to the Ergo node API, including authentication and endpoint URL. ### Endpoints #### API Key - **apiKey** (String) - Required - The API key used for Ergo node API authentication. This is a secret key whose hash was used in the Ergo node configuration. #### API URL - **apiUrl** (String) - Required - The URL of the Ergo node API endpoint. ### Request Example ```json { "apiKey": "your_api_key_hash", "apiUrl": "http://localhost:8080" } ``` ### Response #### Success Response (200) - **message** (String) - Confirmation message indicating successful configuration. #### Response Example ```json { "message": "Ergo node API configuration updated successfully." } ``` ```