{"id":18000149,"url":"https://github.com/termoose/nkn_client","last_synced_at":"2025-08-12T06:05:57.306Z","repository":{"id":62430083,"uuid":"141452848","full_name":"termoose/nkn_client","owner":"termoose","description":"Elixir client for NKN","archived":false,"fork":false,"pushed_at":"2020-07-07T10:43:53.000Z","size":92,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-10T18:59:28.230Z","etag":null,"topics":["elixir","nkn"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/termoose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-18T15:18:29.000Z","updated_at":"2024-08-08T18:15:50.000Z","dependencies_parsed_at":"2022-11-01T19:47:24.209Z","dependency_job_id":null,"html_url":"https://github.com/termoose/nkn_client","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/termoose/nkn_client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termoose%2Fnkn_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termoose%2Fnkn_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termoose%2Fnkn_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termoose%2Fnkn_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/termoose","download_url":"https://codeload.github.com/termoose/nkn_client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/termoose%2Fnkn_client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269933162,"owners_count":24499220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","nkn"],"created_at":"2024-10-29T23:09:53.076Z","updated_at":"2025-08-12T06:05:57.283Z","avatar_url":"https://github.com/termoose.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NknClient\n\nAn Elixir client for sending and receiving messages on [NKN](https://nkn.org).\nClient defaults to compressed elliptic curve points on `NIST P-256`. Support for `ed25519` will be [added in the future](https://github.com/nknorg/nkn/issues/74) once the offical nodes support it.\n\nAutomatically reconnects to the correct node from body of the `WrongNode` messages in accordance with the reference JavaScript Client.\n\nA simple usage example\n\n```elixir\ndefmodule User do\n  use NknClient\n\n  def start_link(state) do\n    NknClient.start_link(__MODULE__, state)\n  end\n\n  def handle_packet(packet) do\n    Logger.debug(\"Packet: #{inspect(packet)}\")\n  end\nend\n```\n\nCallback that can be implemented:\n\n- `handle_packet/1`\n- `handle_update_chain/1`\n- `handle_set_client/1`\n- `handle_send_packet/1`\n- `handle_raw_block/1`\n\nThe module `User` can then be put in a supervision tree or started manually\n\n```elixir\n{:ok, pid} = User.start_link(:ok)\n```\n\nSend packets to other users on the network\n\n```elixir\niex\u003e User.send_packet(\"some_address\", \"Hello, NKN!\")\niex\u003e User.send_packet([\"some_address\", \"another_address\"], \"Hello, NKN!\")\n```\n\nGet your own key pair and client id\n\n```elixir\niex\u003e User.get_keys()\niex\u003e User.get_address()\n```\n\n## Config\n\nAny of the fields can be left blank. If `client_id` is not specified then only the public key will be used for identification. If the `private_key` is left blank then a new one will be generated every time your application starts. If `rpc_url` is left blank the current public default one `http://testnet-node-0001.nkn.org:30003` will be used.\n\nDo not place your private key in your repository, set it as an environment variable and access it with `System.get_env(\"SECRET_NKN_PRIVATE_KEY\")`.\n\n```elixir\nconfig :nkn_client, client_id: \"elixir_nkn\",\n                    private_key: \"some_private_key\",\n                    rpc_url: \"http://custom_seed_rpc:30003\"\n```\n\n## Installation\n\nAdd `nkn_client` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:nkn_client, \"~\u003e 0.5.0\"}\n  ]\nend\n```\n\n## TODO\n\n- ~~Support client id's in front of the public keys (`id.pub_key`)~~\n- ~~Let users specify their own private key and calculate corresponding public key~~\n- ~~Make handle functions for each of the different message types~~\n- ~~Can the \"Digest\" in packages be decoded to reveal information about the relay?~~\n- Add a non-empty `Signature` to sent messages\n- ~~Store the data from updateSigChainBlockHash and expose it through the library API~~ (Callback added)\n- Write more tests!\n- Declare type specifications on all functions\n- Investigate how we can achieve better throughput with our GenStage","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftermoose%2Fnkn_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftermoose%2Fnkn_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftermoose%2Fnkn_client/lists"}