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 参数,我们告诉我们的引擎,到何处找到一个包含我们加密私钥的“秘钥文件”。 通过 polyswarm-client (和其他 PolySwarm 项目) 分发的所有密钥文件都使用一个简单的密码进行加密: password,通过 --password 参数指定。

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 中管理您的帐户


为您的钱包充入资金

一旦您生成了自己的密钥文件,您将需要使用 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!