{"id":26233662,"url":"https://github.com/docknetwork/scale-codec-go","last_synced_at":"2025-12-24T17:32:22.579Z","repository":{"id":57521349,"uuid":"214231476","full_name":"docknetwork/scale-codec-go","owner":"docknetwork","description":"Go SCALE-Codec Library ","archived":false,"fork":false,"pushed_at":"2019-10-16T20:08:47.000Z","size":1236,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-20T16:39:22.561Z","etag":null,"topics":["scale-codec"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/docknetwork.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":"2019-10-10T16:24:30.000Z","updated_at":"2021-10-05T12:46:31.000Z","dependencies_parsed_at":"2022-09-26T18:01:17.753Z","dependency_job_id":null,"html_url":"https://github.com/docknetwork/scale-codec-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docknetwork%2Fscale-codec-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docknetwork%2Fscale-codec-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docknetwork%2Fscale-codec-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docknetwork%2Fscale-codec-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/docknetwork","download_url":"https://codeload.github.com/docknetwork/scale-codec-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243318783,"owners_count":20272145,"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":["scale-codec"],"created_at":"2025-03-13T01:16:59.934Z","updated_at":"2025-12-24T17:32:22.551Z","avatar_url":"https://github.com/docknetwork.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Golang SCALE Codec\n=\nThis is an implementation of Scale-codec in go. \nThe following implementations were used as a reference:\n* [Python](https://github.com/polkascan/py-scale-codec)\n* [Rust](https://github.com/paritytech/parity-scale-codec)\n\n\nTo know more about the role of this library check this [link](https://medium.com/polkadot-network/polkascan-development-update-1-8451c4fcfc2e).\n\nAnd more info about CODEC types is [here](https://polkadot.js.org/api/types/#codec-types).\n\nInstallation\n-\n\nDo\n```shell script\ngo get github.com/docknetwork/scale-codec-go/codec\n```\nor from cloned repo\n```shell script\ncd codec \u0026\u0026 go install\n``` \n\nExamples\n-\nParsing primitive types:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"scale/codec\"\n)\n\nfunc main() {\n\toffsetBytes, err := codec.NewBytes(\"0x02093d00\")\n\tvalue, err := offsetBytes.ToCompactUInt32()\n\tfmt.Println(value, err)\n    // 1000000 \u003cnil\u003e\n}\n```\n\nParsing bytes to existing structure:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"scale/codec\"\n)\n\n\nfunc main() {\n\toffsetBytes, err := codec.NewBytes(\"0x0c00\")\n\tprefs, err := offsetBytes.ToValidatorPrefsLegacy()\n\tfmt.Println(prefs.UnstakeThreshold, err)\n    // 3 \u003cnil\u003e  \n}\n```\n\nCreating your own structure:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"scale/codec\"\n)\n\ntype ValidatorPrefsLegacy struct {\n\tUnstakeThreshold codec.U32\n\tValidatorPayment codec.Balance\n}\n\nfunc ToValidatorPrefsLegacy(sb *codec.OffsetBytes) (res ValidatorPrefsLegacy, err error) {\n\tunstakeThreshold, err := sb.ToCompactUInt32()\n\tif err != nil {\n\t\treturn\n\t}\n\tvalidatorPayment, err := sb.ToCompactBalance()\n\tif err != nil {\n\t\treturn\n\t}\n\tres.UnstakeThreshold = unstakeThreshold\n\tres.ValidatorPayment = validatorPayment\n\treturn\n}\n\nfunc main() {\n\toffsetBytes, err := codec.NewBytes(\"0x0c00\")\n\tprefs, err := ToValidatorPrefsLegacy(\u0026offsetBytes)\n\tfmt.Println(prefs.UnstakeThreshold, err)\n    // 3 \u003cnil\u003e  \n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocknetwork%2Fscale-codec-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdocknetwork%2Fscale-codec-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocknetwork%2Fscale-codec-go/lists"}