{"id":13573049,"url":"https://github.com/hukkin/cosmospy","last_synced_at":"2025-03-15T13:31:00.500Z","repository":{"id":37974591,"uuid":"190628388","full_name":"hukkin/cosmospy","owner":"hukkin","description":"Python tools for Cosmos wallet management and offline transaction signing","archived":true,"fork":false,"pushed_at":"2024-10-14T17:53:31.000Z","size":210,"stargazers_count":88,"open_issues_count":6,"forks_count":57,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-05T16:13:07.039Z","etag":null,"topics":["address","blockchain","cosmos","cosmos-sdk","cryptocurrency","python","tendermint","transaction"],"latest_commit_sha":null,"homepage":"","language":"Python","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/hukkin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-06T18:13:13.000Z","updated_at":"2025-02-20T11:29:26.000Z","dependencies_parsed_at":"2023-01-31T01:01:11.323Z","dependency_job_id":"3959a881-a207-4e5c-b330-271869bec5e3","html_url":"https://github.com/hukkin/cosmospy","commit_stats":{"total_commits":165,"total_committers":3,"mean_commits":55.0,"dds":0.07272727272727275,"last_synced_commit":"eb639d664e989751c555e9b5701a8ef05e929834"},"previous_names":["hukkinj1/cosmospy"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hukkin%2Fcosmospy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hukkin%2Fcosmospy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hukkin%2Fcosmospy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hukkin%2Fcosmospy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hukkin","download_url":"https://codeload.github.com/hukkin/cosmospy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735804,"owners_count":20339532,"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","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":["address","blockchain","cosmos","cosmos-sdk","cryptocurrency","python","tendermint","transaction"],"created_at":"2024-08-01T15:00:28.311Z","updated_at":"2025-03-15T13:31:00.181Z","avatar_url":"https://github.com/hukkin.png","language":"Python","funding_links":[],"categories":["Client Libraries"],"sub_categories":["Python"],"readme":"[![Build Status](https://github.com/hukkin/cosmospy/workflows/Tests/badge.svg?branch=master)](https://github.com/hukkin/cosmospy/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush)\n[![codecov.io](https://codecov.io/gh/hukkin/cosmospy/branch/master/graph/badge.svg)](https://codecov.io/gh/hukkin/cosmospy)\n[![PyPI version](https://img.shields.io/pypi/v/cosmospy)](https://pypi.org/project/cosmospy)\n\n# cosmospy\n\n\u003c!--- Don't edit the version line below manually. Let bump2version do it for you. --\u003e\n\n\u003e Version 6.0.0\n\n\u003e Tools for Cosmos wallet management and offline transaction signing\n\n**Table of Contents**  *generated with [mdformat-toc](https://github.com/hukkin/mdformat-toc)*\n\n\u003c!-- mdformat-toc start --slug=github --maxlevel=6 --minlevel=2 --\u003e\n\n- [Installing](#installing)\n- [Usage](#usage)\n  - [Generating a wallet](#generating-a-wallet)\n  - [Converter functions](#converter-functions)\n    - [Mnemonic seed to private key](#mnemonic-seed-to-private-key)\n    - [Private key to public key](#private-key-to-public-key)\n    - [Public key to address](#public-key-to-address)\n    - [Private key to address](#private-key-to-address)\n  - [Signing transactions](#signing-transactions)\n\n\u003c!-- mdformat-toc end --\u003e\n\n## Installing\u003ca name=\"installing\"\u003e\u003c/a\u003e\n\nInstalling from PyPI repository (https://pypi.org/project/cosmospy):\n\n```bash\npip install cosmospy\n```\n\n## Usage\u003ca name=\"usage\"\u003e\u003c/a\u003e\n\n### Generating a wallet\u003ca name=\"generating-a-wallet\"\u003e\u003c/a\u003e\n\n```python\nfrom cosmospy import generate_wallet\n\nwallet = generate_wallet()\n```\n\nThe value assigned to `wallet` will be a dictionary just like:\n\n```python\n{\n    \"seed\": \"arch skill acquire abuse frown reject front second album pizza hill slogan guess random wonder benefit industry custom green ill moral daring glow elevator\",\n    \"derivation_path\": \"m/44'/118'/0'/0/0\",\n    \"private_key\": b\"\\xbb\\xec^\\xf6\\xdcg\\xe6\\xb5\\x89\\xed\\x8cG\\x05\\x03\\xdf0:\\xc9\\x8b \\x85\\x8a\\x14\\x12\\xd7\\xa6a\\x01\\xcd\\xf8\\x88\\x93\",\n    \"public_key\": b\"\\x03h\\x1d\\xae\\xa7\\x9eO\\x8e\\xc5\\xff\\xa3sAw\\xe6\\xdd\\xc9\\xb8b\\x06\\x0eo\\xc5a%z\\xe3\\xff\\x1e\\xd2\\x8e5\\xe7\",\n    \"address\": \"cosmos1uuhna3psjqfxnw4msrfzsr0g08yuyfxeht0qfh\",\n}\n```\n\n### Converter functions\u003ca name=\"converter-functions\"\u003e\u003c/a\u003e\n\n#### Mnemonic seed to private key\u003ca name=\"mnemonic-seed-to-private-key\"\u003e\u003c/a\u003e\n\n```python\nfrom cosmospy import BIP32DerivationError, seed_to_privkey\n\nseed = (\n    \"teach there dream chase fatigue abandon lava super senior artefact close upgrade\"\n)\ntry:\n    privkey = seed_to_privkey(seed, path=\"m/44'/118'/0'/0/0\")\nexcept BIP32DerivationError:\n    print(\"No valid private key in this derivation path!\")\n```\n\n#### Private key to public key\u003ca name=\"private-key-to-public-key\"\u003e\u003c/a\u003e\n\n```python\nfrom cosmospy import privkey_to_pubkey\n\nprivkey = bytes.fromhex(\n    \"6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa\"\n)\npubkey = privkey_to_pubkey(privkey)\n```\n\n#### Public key to address\u003ca name=\"public-key-to-address\"\u003e\u003c/a\u003e\n\n```python\nfrom cosmospy import pubkey_to_address\n\npubkey = bytes.fromhex(\n    \"03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775\"\n)\naddr = pubkey_to_address(pubkey)\n```\n\n#### Private key to address\u003ca name=\"private-key-to-address\"\u003e\u003c/a\u003e\n\n```python\nfrom cosmospy import privkey_to_address\n\nprivkey = bytes.fromhex(\n    \"6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa\"\n)\naddr = privkey_to_address(privkey)\n```\n\n### Signing transactions\u003ca name=\"signing-transactions\"\u003e\u003c/a\u003e\n\n```python\nfrom cosmospy import Transaction\n\ntx = Transaction(\n    privkey=bytes.fromhex(\n        \"26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59\"\n    ),\n    account_num=11335,\n    sequence=0,\n    fee=1000,\n    gas=70000,\n    memo=\"\",\n    chain_id=\"cosmoshub-4\",\n    sync_mode=\"sync\",\n)\ntx.add_transfer(\n    recipient=\"cosmos103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf\", amount=387000\n)\ntx.add_transfer(recipient=\"cosmos1lzumfk6xvwf9k9rk72mqtztv867xyem393um48\", amount=123)\npushable_tx = tx.get_pushable()\n\n\n# Optionally submit the transaction using your preferred method.\n# This example uses the httpx library.\nimport httpx\n\napi_base_url = \"https://node.atomscan.com\"\nhttpx.post(api_base_url + \"/txs\", data=pushable_tx)\n```\n\nOne or more token transfers can be added to a transaction by calling the `add_transfer` method.\n\nWhen the transaction is fully prepared, calling `get_pushable` will return a signed transaction in the form of a JSON string.\nThis can be used as request body when calling the `POST /txs` endpoint of the [Cosmos REST API](https://cosmos.network/rpc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhukkin%2Fcosmospy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhukkin%2Fcosmospy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhukkin%2Fcosmospy/lists"}