{"id":15713640,"url":"https://github.com/wout/cardano-kit","last_synced_at":"2025-10-26T11:05:05.721Z","repository":{"id":136330776,"uuid":"593221093","full_name":"wout/cardano-kit","owner":"wout","description":"At toolkit for Crystal to ease development for the Cardano blockchain.","archived":false,"fork":false,"pushed_at":"2023-02-05T08:24:19.000Z","size":28,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T18:47:05.022Z","etag":null,"topics":["bech32","cardano","cardano-addresses","cbor","cip08","cip30","crystal","crystal-lang","ed25519"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/wout.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-25T14:18:07.000Z","updated_at":"2023-07-25T15:06:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"f258df31-9500-4b1f-b439-c3d7d32c1338","html_url":"https://github.com/wout/cardano-kit","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/wout/cardano-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fcardano-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fcardano-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fcardano-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fcardano-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wout","download_url":"https://codeload.github.com/wout/cardano-kit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wout%2Fcardano-kit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281092753,"owners_count":26442440,"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-10-26T02:00:06.575Z","response_time":61,"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":["bech32","cardano","cardano-addresses","cbor","cip08","cip30","crystal","crystal-lang","ed25519"],"created_at":"2024-10-03T21:32:35.121Z","updated_at":"2025-10-26T11:05:05.682Z","avatar_url":"https://github.com/wout.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cardano-kit\n\nAt toolkit for Crystal to ease developing for the Cardano blockchain.\n\nThis shard consists of a series of individual modules that can be combined or\nused separately. The main goal is to provide a series of abstractions for\ncomplex implementations, thereby lowering the barriers to entry for development \non Cardano. It's very much a work in progress, but the contained modules are \nready for use in production.\n\n![GitHub](https://img.shields.io/github/license/wout/cardano-kit)\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/wout/cardano-kit)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/wout/cardano-kit/ci.yml?branch=main)\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n  ```yaml\n  dependencies:\n    cardano_kit:\n      github: wout/cardano-kit\n  ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"cardano_kit\"\n```\n\n### Address\n\nParse an address from bech32 to its prefix and words:\n\n```crystal\naddress = CardanoKit::Address.from_bech32(\"addr1qxdvcswn0exwc2vjfr6u6f6qndf...\")\nputs address.prefix\n# =\u003e \"addr\"\nputs address.words\n# =\u003e Bytes[0, 4, 223, 149, 66, 179, 36, 18, 22, 136, 65, 58, 246, 181, 214, ...]\n```\n\nOr parse it from hexbytes using a string or bytes object:\n\n```crystal\nCardanoKit::Address.from_bytes(\"addr\", Bytes[0, 4, 223, 149, 66, 179, 36, ...])\n# or\nCardanoKit::Address.from_hexstring(\"addr\", \"0004df9542b324121688413af6b5d6c...\")\n```\n\nConvert an address to bech32 format:\n\n```crystal\nputs address.to_bech32\n# =\u003e \"addr1qxdvcswn0exwc2vjfr6u6f6qndfhmk94xjrt5tztpelyk4yg83zn9d4vrrtzs98lc...\"\n```\n\nFind the stake address for a given address:\n\n```crystal\nputs address.stake_address\n# =\u003e \"stake1uxyrc3fjk6kp343gznlu06w2qddk0f5d5r4znrxzg52zxlclk0hlq\"\n```\n\nIf a short address is provided without the stake address part, this method will\nraise a `CardanoKit::NoStakeAddressException`. The `stake_address?` variant of\nthis method will return `nil` in that case, which may be preferable in some\nscenarios.\n\nFinally, an address object can be initialized directly with its prefix and words\narguments:\n\n```crystal\nCardanoKit::Address.new(\"addr\", Bytes[0, 4, 223, 149, 66, 179, 36, 18, 22, ...])\n```\n\nHowever, initializing it with an unknown prefix will raise a\n`CardanoKit::UnknownPrefixExcepiton`. A safer, but more verbose way to\ninitialize an address is to use the underlying enums:\n\n```crystal\nCardanoKit::Address.new(\n  CardanoKit::AddrPrefix::Mainnet,\n  Bytes[0, 4, 223, 149, 66, 179, 36, 18, 22, 136, 65, 58, 246, 181, 214, ...]\n)\n```\n\nMaking a typo there will result in a compile-time error, thus avoiding a dreaded\nruntime error. Available values are:\n\n```crystal\nCardanoKit::AddrPrefix::Testnet # =\u003e \"addr_test\"\nCardanoKit::AddrPrefix::Mainnet # =\u003e \"addr\"\nCardanoKit::AddrPrefix::StakeTestnet # =\u003e \"stake_test\"\nCardanoKit::AddrPrefix::StakeMainnet # =\u003e \"stake\"\n```\n\n### CIP08\n\nAn implementation of\n[CIP08](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0008) for\nwallet signature verification on Cardano.\n\nMost common use cases:\n1. Proving ownership of a set address.\n2. Proving ownership of addresses used in a transaction.\n3. Proving ownership of an identity or other off-chain data with a public key attached to it.\n\n```crystal\ncip08 = CardanoKit::CIP08.new(key, signature)\n\n# validate the signature\nif cip08.signature_valid?\n  # get the message\n  puts cip08.message\n  # =\u003e \"Hello Crystal!\"\n\n  # define the address prefix based on the used network (1 is mainnet, 0 for testnets)\n  prefix = CardanoKit::AddrPrefix.from_value(1)\n\n  # get the address object\n  puts cip08.address(prefix).to_s\n  # =\u003e \"addr1qqe63xlwltvt0dehyzqdn82eugy79egwzr35pwuu3wrzeqglaeslj4r7yyt83kt...\"\nelse\n  puts \"Invalid signature!\"\nend\n```\n\nAlternatively, the CIP08 object can be initialized with the signed data object\nprovided by the client. This will relieve you from having to parse the user data\nand it adds an extra layer of type safety:\n\n```crystal\njson_from_client = %({\"key\":\"...\",\"signature\":\"...\"})\nsigned_data = CardanoKit::CIP08::SignedData.from_json(json_from_client)\ncip08 = CardanoKit::CIP08.new(signed_data)\n```\n\n**Note**: In its current state, this library won't look in the headers of the\nsignature, so the COSE key should be provided separately.\n\n## Development\n\nMake sure you have [Guardian.cr](https://github.com/f/guardian) installed. Then\nrun:\n\n```bash\n$ guardian\n```\n\nThis will automatically:\n- run ameba for src and spec files\n- run the relevant spec for any file in the src dir\n- run spec a file whenever it's saved\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/wout/cardano-kit/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Wout](https://github.com/wout) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwout%2Fcardano-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwout%2Fcardano-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwout%2Fcardano-kit/lists"}