{"id":30412751,"url":"https://github.com/lazureykis/borsh_serializer","last_synced_at":"2025-08-22T02:10:04.134Z","repository":{"id":43795126,"uuid":"427049337","full_name":"lazureykis/borsh_serializer","owner":"lazureykis","description":"Native Elixir BORSH serializer","archived":false,"fork":false,"pushed_at":"2022-02-18T10:08:57.000Z","size":50,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-19T09:26:08.376Z","etag":null,"topics":["borsh","elixir","elixir-lang","elixir-language","native","serialization"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lazureykis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-11T15:25:18.000Z","updated_at":"2025-08-07T11:49:04.000Z","dependencies_parsed_at":"2022-08-21T22:21:13.080Z","dependency_job_id":null,"html_url":"https://github.com/lazureykis/borsh_serializer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lazureykis/borsh_serializer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazureykis%2Fborsh_serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazureykis%2Fborsh_serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazureykis%2Fborsh_serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazureykis%2Fborsh_serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lazureykis","download_url":"https://codeload.github.com/lazureykis/borsh_serializer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazureykis%2Fborsh_serializer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271574431,"owners_count":24783319,"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-22T02:00:08.480Z","response_time":65,"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":["borsh","elixir","elixir-lang","elixir-language","native","serialization"],"created_at":"2025-08-22T02:10:03.483Z","updated_at":"2025-08-22T02:10:04.119Z","avatar_url":"https://github.com/lazureykis.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Borsh binary serializer\n\n![Tests](https://github.com/lazureykis/borsh_serializer/actions/workflows/elixir.yml/badge.svg?branch=master)\n[![Hex.pm](https://img.shields.io/hexpm/v/borsh_serializer.svg)](https://hex.pm/packages/borsh_serializer)\n\n[Borsh](https://borsh.io) is a binary serializer for security-critical projects.\n\n`borsh_serializer` supports base58-encoded binary fields (Solana public keys as strings).\n\n## Installation\n\nThis library requires Elixir 1.11 or above.\n\nAdd `borsh_serializer` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:borsh_serializer, \"~\u003e 1.0\"},\n\n    # Add :b58 if you need :base58 data type support\n    {:b58, \"~\u003e 1.0.2\"},\n  ]\nend\n```\n\n## Usage\n\n```elixir\n# Define struct and its borsh schema:\n\ndefmodule Person do\n  @moduledoc false\n  defstruct id: 0, name: nil, email: nil\n\n  def borsh_schema do\n    [\n      {:id, :u16},\n      {:name, :string},\n      {:wallet, {:base58, 32}}\n    ]\n  end\nend\n\nperson = %Person{id: 123, name: \"John\", wallet: \"Hj1bMz4GZyRANWxBEzm6hh29Mk54f9YMh8mBiWy1PUXE\"}\n# Encode into binary\nbindata = Borsh.encode(person)\n# Decode from binary\n{person, \"\"} = Borsh.decode(bindata, Person)\n```\n\nFor a complex example, take a look at [Metaplex Metadata schema](https://github.com/lazureykis/borsh_serializer/blob/master/test/support/metaplex_schema.ex) I used for tests.\n\n## Data Types\n\nTo define a schema, you must implement `borsh_schema/0` method, which returns a list of field definitions.\nEach field definition is a tuple `{:field_name, :field_type}`.\n\nSupported data types with examples:\n\n```elixir\n# Unsigned integers\n:u8, :u16, :u32, :u64, :u128\n# Examples:\n{:age, :u8}\n{:counter, :u128}\n\n\n# Signed integers\n:i8, :i16, :i32, :i64, :i128\n# Example:\n{:amount, :i32}\n\n\n# Float numbers\n:f32, :f64\n# Example:\n{:temp, :f32}\n\n\n# String type:\n:string\n# Example:\n{:username, :string}\n\n\n# Enum values are encoded as u8 and are zero-indexed\n{:enum, values}\n# Example:\n{:color, {:enum, [\"red\", \"green\", \"blue\"]}}\n\n\n# Fixed size array\n{:array, item_type, array_size}\n# Example:\n{:numbers, {:array, :u32, 5}}\n\n\n# Dynamic size array\n{:array, :item_type}\n# Example:\n{:tags, {:array, :string}}\n\n\n# Optional fields\n{:option, field_definition}\n# Examples:\n{:username, {:option, :string}}\n{:tags, {:option, {:array, :string}}}\n\n\n# Embedded Structs\n{:struct, module}\n# Examples:\n{:user, {:struct, MyUserStructModule}}\n\n# Binary Data\n{:binary, byte_size}, {:base64, byte_size}, {:base58, byte_size}\n# Examples:\n{:rawdata, {:binary, 256}}\n{:pubkey, {:base58, 32}}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazureykis%2Fborsh_serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazureykis%2Fborsh_serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazureykis%2Fborsh_serializer/lists"}