{
    "$meta": {
        "description": "A `coin` object can be obtained by using [get_coin](#BLOCKCHAIN_GET_COIN). The `classID` used for this object is `\"coin\"`."
    },
    "set_cycle_mining": {
        "description": "Defines the interval (in-game hours) in which each user receives a coin reward when mining. The interval cannot be lower than 1 and not higher than 2160. If the provided `rateHours` is not a `number`, this method will return `null`. On success, it will return a `number` with the value one. In case of failure, the method will return a `string` with details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.set_cycle_mining(20)",
            "if result == 1 then",
            "    print \"Successful updated mining interval\"",
            "else",
            "    print \"Failed updating mining interval\"",
            "end if"
        ]
    },
    "get_cycle_mining": {
        "description": "Returns a `number` representing the defined interval in which each user receives a coin reward when mining. In case of failure, the method will return a `string` with details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.get_cycle_mining",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed getting cyclic mining value due to: \" + result",
            "end if",
            "print \"cyclic mining value: \" + result"
        ]
    },
    "get_reward": {
        "description": "Returns a `number` representing the amount of coins that will be received as a reward after each mining cycle. In case of failure, the method will return a `string` with details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.get_reward",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed getting reward value due to: \" + result",
            "end if",
            "print \"reward value: \" + result"
        ]
    },
    "set_reward": {
        "description": "Assigns the reward that miners will receive after each mining cycle. The reward value has to be above one. If the provided `coinAmount` is not a `number`, this method will return `null`. On success, it will return a `number` with the value one. In case of failure, the method will return a `string` with details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.set_reward(-1)",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed setting reward due to: \" + result",
            "end if",
            "print \"Successfully set reward!\""
        ]
    },
    "transaction": {
        "description": "Facilitates a transaction of the currency between the indicated subwallets. In case of an error, a `string` with the details is returned. In case of success, a `number` with a value of one will be returned. If any of the provided parameters have a type that deviates from the defined signature, the method will return `null`.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.transaction(\"test\", \"test2\", 20)",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed transaction due to: \" + result",
            "end if",
            "print \"Successfully transfered!\""
        ]
    },
    "create_subwallet": {
        "description": "Registers a new account in the `coin` that can be used to manage services such as stores. It is necessary to provide the PIN of the owner's `wallet` that wants to register. In case of success, the method will return a `number` with the value one. If any of the provided parameters have a type that deviates from the defined signature, the method will return `null`. In case of an error, a `string` with the details is returned.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "wallet = blockchain.login_wallet(\"test\", \"test\")",
            "result = coin.create_subwallet(\"test\", wallet.get_pin, \"test\", \"test\")",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed to create subwallet due to: \" + result",
            "end if",
            "print \"Successfully created subwallet!\""
        ]
    },
    "get_subwallet": {
        "description": "Returns a `subWallet` object on success. In case of error, it returns a `string` with the details. If the provided `subWalletUser` is not a `string`, this method will return `null`.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.get_subwallet(\"test\")",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed to get subwallet due to: \" + result",
            "end if",
            "print \"Successfully received subwallet!\""
        ]
    },
    "get_subwallets": {
        "description": "Returns a `list` where each item is a `subWallet` object, including all the accounts registered in the cryptocurrency. In case of error, it returns a `string` with the details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.get_subwallets",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed to get subwallets due to: \" + result",
            "end if",
            "for subwallet in result",
            "    print subwallet.get_user + \" has \" + subwallet.get_balance + \" coins\"",
            "end for"
        ]
    },
    "set_address": {
        "description": "Configures a valid address that will be shown to users who do not have the currency, indicating where to register. In case of an error, it returns a `string` with the details. In case of success, a `number` with a value of one will be returned. If the provided address is not a `string`, this method will return `null`.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.set_address(\"12.12.12.12\")",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed to set address due to: \" + result",
            "end if",
            "print \"Successfully set address!\""
        ]
    },
    "get_address": {
        "description": "Returns the configured address that will be shown to users who do not have the currency, indicating where they have to register. In case of an error, it returns a `string` with details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.get_address",
            "if not is_valid_ip(result) then",
            "    exit \"Failed to get address due to: \" + result",
            "end if",
            "print \"address: \" + result"
        ]
    },
    "get_mined_coins": {
        "description": "Returns a `number` representing the amount of coins that have been mined so far. In case of an error, it returns a `string` with details.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.get_mined_coins",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed to get mined coins due to: \" + result",
            "end if",
            "print \"mined coins: \" + result"
        ]
    },
    "reset_password": {
        "description": "Resets the password of the coin. It returns a `number` with the value one if resetting was successful; otherwise, it will return a `string`.",
        "example": [
            "blockchain = include_lib(\"/lib/blockchain.so\")",
            "coin = blockchain.get_coin(\"test\", \"test\", \"test\")",
            "result = coin.reset_password(\"test\")",
            "if typeof(result) == \"string\" then",
            "    exit \"Failed to reset password due to: \" + result",
            "end if",
            "print \"Successfully reset password\""
        ]
    }
}
