 
         static internal func asTransaction (json: JSON, rid: Int32) -> ETH.Transaction? {
             guard let hash = json.asString(name: "hash"),
-                let sourceAddr = json.asString(name: "from"),
-                let targetAddr = json.asString(name: "to"),
+                let sourceAddr   = json.asString(name: "from"),
+                let targetAddr   = json.asString(name: "to"),
                 let contractAddr = json.asString(name: "contractAddress"),
-                let amount     = json.asString(name: "value"),
-                let gasLimit   = json.asString(name: "gas"),
-                let gasPrice   = json.asString(name: "gasPrice"),
-                let data       = json.asString(name: "input"),
-                let nonce      = json.asString(name: "nonce"),
-                let gasUsed    = json.asString(name: "gasUsed"),
-                let blockNumber    = json.asString(name: "blockNumber"),
-                let blockHash      = json.asString(name: "blockHash"),
+                let amount       = json.asString(name: "value"),
+                let gasLimit     = json.asString(name: "gas"),
+                let gasPrice     = json.asString(name: "gasPrice"),
+                let data         = json.asString(name: "input"),
+                let nonce        = json.asString(name: "nonce"),
+                let gasUsed      = json.asString(name: "gasUsed"),
+                let blockNumber  = json.asString(name: "blockNumber"),
+                let blockHash    = json.asString(name: "blockHash"),
                 let blockConfirmations    = json.asString(name: "confirmations"),
                 let blockTransactionIndex = json.asString(name: "transactionIndex"),
                 let blockTimestamp        = json.asString(name: "timeStamp"),
-                let isError    = json.asString(name: "isError")
+                let isError      = json.asString(name: "isError")
                 else { return nil }
 
             return (hash: hash,

        }
    }

    /// ...

    /// BTC
    public struct BTC {
        typealias Transaction = (btc: BRCoreTransaction, rid: Int32)

    }

    internal func getBlockNumberAsBTC (bwm: BRWalletManager,
                                       blockchainId: String,
                                       rid: Int32,
                                       done: @escaping (UInt64, Int32) -> Void) {
        getBlockchain (blockchainId: blockchainId) { (res: Result<BlockChainDB.Model.Blockchain, BlockChainDB.QueryError>) in
            switch res {
            case let .success (blockchain):
                done (blockchain.blockHeight, rid)

            }

            do {
                guard let json = try JSONSerialization.jsonObject(with: data, options: []) as? T
                    else {
                        print ("SYS: API: ERROR: JSON.Dict: \(data.map { String(format: "%c", $0) }.joined())")
                        completion (Result.failure(QueryError.jsonParse(nil)));
                        return }

                completion (Result.success (json))
            }
            catch let jsonError as NSError {
                print ("SYS: API: ERROR: JSON.Error: \(data.map { String(format: "%c", $0) }.joined())")
                completion (Result.failure (QueryError.jsonParse (jsonError)))
                return
            }
            }.resume()
    }

    internal func makeRequest<T> (_ dataTaskFunc: DataTaskFunc,
                                  _ baseURL: String,
                                  path: String,
                                  query: Zip2Sequence<[String],[String]>? = nil,
                                  data: JSON.Dict? = nil,
                                  httpMethod: String = "POST",
                                  completion: @escaping (Result<T, QueryError>) -> Void) {
        guard var urlBuilder = URLComponents (string: baseURL)
            else { completion (Result.failure(QueryError.url("URLComponents"))); return }

        urlBuilder.path = path.starts(with: "/") ? path : "/\(path)"
        if let query = query {
            urlBuilder.queryItems = query.map { URLQueryItem (name: $0, value: $1) }
        }

        guard let url = urlBuilder.url
            else { completion (Result.failure (QueryError.url("URLComponents.url"))); return }

        print ("SYS: Request: \(url.absoluteString): Data: \(data?.description ?? "[]")")

        var request = URLRequest (url: url)
        request.addValue ("application/json", forHTTPHeaderField: "accept")
        request.addValue ("application/json", forHTTPHeaderField: "Content-Type")
        request.httpMethod = httpMethod

        // If we have data as a JSON.Dict, then add it as the httpBody to the request.
        if let data = data {
            do { request.httpBody = try JSONSerialization.data (withJSONObject: data, options: []) }
            catch let jsonError as NSError {
                completion (Result.failure (QueryError.jsonParse(jsonError)))
            }
        }

        sendRequest (request, dataTaskFunc, completion: completion)
    }

    internal func bdbMakeRequest (path: String,
                                  query: Zip2Sequence<[String],[String]>?,
                                  embedded: Bool = true,
                                  completion: @escaping (Bool, Result<[JSON], QueryError>) -> Void) {
        makeRequest (bdbDataTaskFunc, bdbBaseURL,
                     path: path,
                     query: query,
                     data: nil,
                     httpMethod: "GET") { (res: Result<JSON.Dict, QueryError>) in
                        let res = res.map { JSON (dict: $0) }

                        // See if there is a 'page' Dict in the JSON
                        let page: JSON.Dict? = try! res
                            .map { $0.asDict(name: "page") }
                            .recover { (ignore) in return nil }
                            .get()

                        // The page is full if 'total_pages' is more than 1
                        let full: Bool = page.map { (($0["total_pages"] as? Int) ?? 0) > 1 } ?? false

                        // If called not embedded then never be full
                        // precondition (...)

                        // Callback with `more` and the result (maybe error)
                        completion (false, // embedded && full,
                            res.flatMap { (json: JSON) -> Result<[JSON], QueryError> in
                                let json = (embedded
                                    ? json.asDict(name: "_embedded")?[path]
                                    : [json.dict])

                                guard let data = json as? [JSON.Dict]
                                    else { return Result.failure(QueryError.model ("[JSON.Dict] expected")) }

                                return Result.success (data.map { JSON (dict: $0) })
                        })
        }
    }

    internal func apiMakeRequestJSON (ewm: BREthereumEWM, data: JSON.Dict, completion: @escaping (Result<JSON, QueryError>) -> Void) {
        let path = "/ethq/\(BlockChainDB.networkNameFrom(ewm:ewm).lowercased())/proxy"
        makeRequest (apiDataTaskFunc, apiBaseURL,
                     path: path,
                     query: nil,
                     data: data,
                     httpMethod: "POST") { (res: Result<JSON.Dict, QueryError>) in
                        completion (res.map { JSON (dict: $0) })
        }
    }

    internal func apiMakeRequestQUERY (ewm: BREthereumEWM,
                                       query: Zip2Sequence<[String],[String]>?,
                                       data: JSON.Dict,
                                       completion: @escaping (Result<JSON, QueryError>) -> Void) {
        let path = "/ethq/\(BlockChainDB.networkNameFrom(ewm:ewm).lowercased())/query"
        makeRequest (apiDataTaskFunc, apiBaseURL,
                     path: path,
                     query: query,
                     data: data,
                     httpMethod: "POST") { (res: Result<JSON.Dict, QueryError>) in
                        completion (res.map { JSON (dict: $0) })
        }
    }

    internal func apiMakeRequestTOKEN (ewm: BREthereumEWM,
                                       completion: @escaping (Result<[JSON.Dict], QueryError>) -> Void) {
        let path = "/currencies"
        makeRequest (apiDataTaskFunc, apiBaseURL,
                     path: path,
                     query: zip(["type"], ["erc20"]),
                     data: nil,
                     httpMethod: "GET",
                     completion: completion)
    }

    ///
