PolySwarmPolySwarmPolySwarmPolySwarm
Help

Participating in the PolySwarm Marketplace

一旦你徹底測試過了你的微引擎,你會想讓它在真正的 PolySwarm 市場工作!

大致上來說,插入 PolySwarm 市場取決於:

  1. 確定您要加入哪個(些)社區
  2. 將您的引擎指向這些社區的 polyswarmd 託管實例

在執行此操作時,有幾點事項需要注意。我們將在下面討論。


錢包 & 關鍵文件

PolySwarm 是建立於以太坊之上,一個可以編程的世界計算機,並藉由一個稱為 Ether (ETH)的原生加密貨幣來使其運轉。 當一個以太坊的用戶執行一個轉錢動作或是執行一個以太坊 “智能合約” (如 PolySwarm 的 Relay 合約)時,此用戶必須支付瓦斯(Gas)給以太坊網路來執行這項交易。 Gas 會從使用者的 ETH 餘額中扣除。

PolySwarm 使用花蜜幣(NCT)來運行 - 一個建構於以太坊之上的應用層加密貨幣。 NCT 對於參與 PolySwarm 市場是必要的。

作為您在 PolySwarm 市場中的代表,您的引擎,必須能夠訪問 ETH 和 NCT。

加密貨幣錢包

與所有加密貨幣(例如比特幣)一樣,資金在 “錢包” 中維持。 從技術上講,一個錢包只是一個加密密鑰和一些元數據描述了鑰匙的使用情況。 從技術上講,一個錢包只是一個加密密鑰和一些元數據描述了鑰匙的使用情況。 擁有/控制錢包(及其中的所有資金)類似於擁有錢包秘鑰對的私有部分。

In PolySwarm, as with all cryptocurrency applications, an attacker with access to your wallet's private key can steal all your cryptocurrency (ETH & NCT) and impersonate you in the marketplace. It is absolutely essential that you protect the secrecy of your wallet's private key.

意味著確保您的私鑰不在本文檔的範圍內。 為了使您的引擎能夠參與 PolySwarm 市場(並代表您交易),您的引擎必須能夠用您錢包的私鑰簽署交易。 這意味著引擎必須能夠直接訪問密鑰(安全性較低),或者能夠請求能夠訪問秘鑰的設備/過程的簽名。 polyswarm-client 現支持直接密鑰文件訪問方法。 未來的 polyswarm-client 版本將支持將事務簽名卸載到另一台設備。

PolySwarm 錢包使用情況

測試引擎時,我們可以通過對polyswarm-client 實用程序(即micronginebalancanmanager)的--keyfile</0 > 參數,我們告訴我們的引擎,到何處找到一個包含我們加密私鑰的“秘鑰文件”。 通過<code>polyswarm-client (和其他PolySwarm 項目) 分發的所有密鑰文件都使用一個簡單的密碼進行加密: password,通過`--password</ 0> 參數指定。

The sole purpose of these distributed keyfiles is for testing with fake nct and fake eth. Never use testing keyfiles from polyswarm projects in production or in real communities. Never fund the wallets contained in these testing keyfiles with real nct or real eth. When operating outside of a development testing environment you must create your own production keyfile. You are solely responsible for the security of your production keyfile.

官方以太網客戶端(go-ethereum` 或簡潔形式 `geth`)包含生成秘鑰文件的說明。 參閱[在 geth 中管理您的帳戶](https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts)。


為您的錢包充入資金

一旦您生成了自己的密鑰文件,您將需要使用 ETH 和 NCT 為您的錢包充入資金。

一般來說,有三種充入資金的渠道:

  1. 通過加密貨幣交易所購買 ETH 和 NCT,並將其轉入由您的微型生產密鑰文件所代表的生產錢包。 購買和轉移加密貨幣的方法不在本文檔範圍內。
  2. 訂閱 PolySwarm Direct — 一種即將提供的服務,帶有可以配置的可自動重新充值功能,可確保您的引擎有資金。 此服務正在開發中,敬請期待!
  3. 初始夥伴已經按照我們公佈的分發時間表在生產錢包中接收到了 NCT 種子。

尋找您的社區

PolySwarm 市場由一些社區組成。 社區是個人和公司群體,他們都有特定的惡意軟件興趣,或相互同意對在社區內交換的工件保密。

PolySwarm's Lima Community, is a public Community accessible to everyone - it's where you'll want to get started. Lima acts as a sort of "proving ground" for security experts to build a reputation for their engine. 一旦安全專家建立了信譽,他們可能會讓更多的社區參與。 As more communities come online, they'll appear in PolySwarm Portal:

For now, let's proceed under the assumption that we only want to join the Lima Community.

polyswarm-client based engines currently only support communicating with a single Community at a given time. Support for multiple Communities will be included in a future release. In the meantime, please run an instance of your engine (& balancemanager) per Community.


將 NCT 傳遞到您的社區

Recall that each community has a distinct sidechain where PolySwarm transactions occur. In order to participate, you'll need to maintain a balance of NCT (ETH not required) on the Community's sidechain.

We've made this easy: you can use polyswarm-client's balancemanager utility. You'll need to run both your engine and a balancemanager to maintain a balance of NCT on the Community sidechain. Windows users will recall running balancemanager from the integration testing instructions. Linux users had balancemanager handled for them by Docker transparently.

balancemanager can be run in three modes:

  1. 存款:將配置的數量的 NCT 存入社區並退出
  2. 提取:將配置的數量的 NCT 從社區取出並退出
  3. 維持:持續確保社區中有可配置餘額的 NCT

Most users will want to simply maintain a balance - we'll dive into using this functionality below. Advanced users may want to manually deposit and withdraw funds.


API Keys

In order to protect themselves from griefing / Denial of Service (DoS), Communities may elect to issue their members API keys and apply rate limits to these keys. Lima is one such Community, but API keys are available to everyone.

To obtain your API key, sign up on PolySwarm Portal, click your name in the top right corner and select Account. Your API key will be displayed in your Profile.

在基於 polyswarm-client 的引擎中使用 API 密鑰

Using your API key in polyswarm-client based engines is as simple as populating the --api-key command line argument. We discuss this below.

在自定義引擎中使用 API 密鑰

If you're building a custom engine, please ensure that all API requests to Community-hosted polyswarmd instances contain your API key in the headers:

Authorization: [API KEY]

For more details on the polyswarmd API, please refer to our API specification polyswarmd API Documentation.


總結

To recap, we've:

  1. 生成一個供生產使用的錢包密鑰文件
  2. 用 ETH 和 NCT 向這個錢包充入了資金
  3. 對我們社區做了決定
  4. 檢索我們社區的 API 密鑰

Now we're ready to plug our engine (& balancemanager) into the PolySwarm marketplace!

If you've built your engine on polyswarm-client, (e.g. using our cookiecutter participant-template in the tutorials here), you simply need to specify some command line arguments (can also be specified as environment variables):

# microengine \
  --polyswarmd-addr lima.polyswarm.network \
  --keyfile <path to your self-generated and funded keyfile> \
  --password <encryption password for your keyfile> \
  --api-key <your API key>
  --backend <the name ("slug") of your scan engine (e.g. acme_eicar)>

For the full list of command line arguments, use the --help CLI flag:

# microengine --help
Usage: microengine [OPTIONS]

Entrypoint for the microengine driver

Args:     log (str): Logging level     polyswarmd_addr(str): Address of
  polyswarmd     keyfile (str): Path to private key file to use to sign
  transactions     password (str): Password to decrypt the encrypted private
  key     backend (str): Backend implementation to use     api_key(str): API
  key to use with polyswarmd     testing (int): Mode to process N bounties
  then exit (optional)     insecure_transport (bool): Connect to polyswarmd
  without TLS     log_format (str): Format to output logs in. `text` or
  `json`

Options:
  --log TEXT              Logging level
  --polyswarmd-addr TEXT  Address (host:port) of polyswarmd instance
  --keyfile PATH          Keystore file containing the private key to use with
                          this microengine
  --password TEXT         Password to decrypt the keyfile with
  --api-key TEXT          API key to use with polyswarmd
  --backend TEXT          Backend to use
  --testing INTEGER       Activate testing mode for integration testing,
                          respond to N bounties and N offers then exit
  --insecure-transport    Connect to polyswarmd via http:// and ws://,
                          mutually exclusive with --api-key
  --chains TEXT           Chain(s) to operate on
  --log-format TEXT       Log format. Can be `json` or `text` (default)
  --help                  Show this message and exit.

In addition to your engine, you'll need to run a balancemanager.

balancemanager will also require access to your keyfile:

# balancemanager maintain \
  --polyswarmd-addr lima.polyswarm.network \
  --keyfile <path to your self-generated and funded keyfile> \
  --password <encryption password for your keyfile> \
  --api-key <your API key> \
  --maximum <(optional) the maximum allowable balance in the Community before a withdraw is made>
  <MINIMUM: deposit into the Community when balance drops below this value>
  <REFILL_AMOUNT: the amount of NCT to transfer when Community balance falls below MINIMUM>

For the full list of command line arguments, use the --help CLI flag:

# balancemanager maintain --help
INFO:root:2018-12-28 03:04:11,352 Logging in text format.
Usage: balancemanager maintain [OPTIONS] MINIMUM REFILL_AMOUNT

Entrypoint to withdraw NCT from a sidechain into the homechain

Args:     minimum (float): Value of NCT on sidechain where you want to
  transfer more NCT     refill-amount (float): Value of NCT to transfer
  anytime the balance falls below the minimum

Options:
  --polyswarmd-addr TEXT   Address (host:port) of polyswarmd instance
  --keyfile PATH           Keystore file containing the private key to use
                           with this microengine
  --password TEXT          Password to decrypt the keyfile with
  --api-key TEXT           API key to use with polyswarmd
  --testing INTEGER        Activate testing mode for integration testing,
                           trigger N balances to the sidechain then exit
  --insecure-transport     Connect to polyswarmd via http:// and ws://,
                           mutually exclusive with --api-key
  --maximum FLOAT          Maximum allowable balance before triggering a
                           withdraw from the sidechain
  --withdraw-target FLOAT  The goal balance of the sidechain after the
                           withdrawal
  --confirmations INTEGER  Number of block confirmations relay requires before
                           approving the transfer
  --help                   Show this message and exit.

Congratulations

With your engine & balancemanager running, you are now plugged into your Community(ies) of choice!