ModulesConnect to a Module

Module Connect

Through ModuleClient

To connect to a miner using CommuneX, you can simply use the ModuleClient class. It would look like this:

client = ModuleClient("localhost", 8000, keypair) result ="do_the_thing", target_key, {"awesomeness": 45, "extra": "hi"}))
  • keypair is the keypair you're going to use on your client. Miners only accept connections from clients with a key registered on the Commune network, and on the same subnet (netuid) as them.
  • target_key is the ss58address of the miner you're going to connect to.

On Your Own

If you don't want to use python to make your requests, you can implement your own client as you wish, but some particularities needs to be followed:

  • Your request should be a json with the fields params, timestamp and target_key.
  • You should include X-Key, X-Crypto and X-Signature on the headers.

timestamp is the ISO timestamp of your request, target_key is the ss58address of the miner that your request is directed at. params is the actual data that the miner expects on the endpoint. This json should be signed to create a SR25519 signature that You're going to put on the X-Signature header. X-Crypto is the type of cryptography of your key (currently only SR25519 is supported) and X-Key is the hexstring of your public key.