{"id":28662774,"url":"https://github.com/subscan-explorer/substrate-api-rpc","last_synced_at":"2025-08-03T19:04:54.023Z","repository":{"id":56700781,"uuid":"279195000","full_name":"subscan-explorer/substrate-api-rpc","owner":"subscan-explorer","description":"Substrate RPC lib","archived":false,"fork":false,"pushed_at":"2025-06-11T08:05:11.000Z","size":122,"stargazers_count":24,"open_issues_count":5,"forks_count":27,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T09:23:18.174Z","etag":null,"topics":["rpc","substrate","websocket"],"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/subscan-explorer.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,"zenodo":null}},"created_at":"2020-07-13T02:58:48.000Z","updated_at":"2025-06-11T08:04:34.000Z","dependencies_parsed_at":"2024-06-18T16:55:41.314Z","dependency_job_id":"f49e0219-4a3f-4420-a64e-51cb029afca5","html_url":"https://github.com/subscan-explorer/substrate-api-rpc","commit_stats":null,"previous_names":["subscan-explorer/substrate-api-rpc","itering/substrate-api-rpc"],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/subscan-explorer/substrate-api-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subscan-explorer%2Fsubstrate-api-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subscan-explorer%2Fsubstrate-api-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subscan-explorer%2Fsubstrate-api-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subscan-explorer%2Fsubstrate-api-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/subscan-explorer","download_url":"https://codeload.github.com/subscan-explorer/substrate-api-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/subscan-explorer%2Fsubstrate-api-rpc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268595791,"owners_count":24275771,"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-03T02:00:12.545Z","response_time":2577,"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":["rpc","substrate","websocket"],"created_at":"2025-06-13T11:12:42.886Z","updated_at":"2025-08-03T19:04:53.782Z","avatar_url":"https://github.com/subscan-explorer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# substrate-api-rpc\n\n## Contents\n\n- [Install](#Install)\n- [Usage](#Usage)\n    - [Codec](#Codec)\n    - [RPC](#RPC)\n- [Contributions](#Contributions)\n- [LICENSE](#LICENSE)\n\n## Install\n\n```\ngo get github.com/itering/substrate-api-rpc\n```\n\n## Usage\n\n### Codec\n\n#### Extrinsic Decode\n\n```\nmetadataRaw := \"\" // rpc state_getMetadata\nspecVersion := 0  // rpc chain_getRuntimeVersion\nencodeExtrinsic := []string{\"0x280402000b10449a7e7301\", \"0x1c0407005e8b4100\"}\ndecodeExtrinsics, err := substrate.DecodeExtrinsic(encodeExtrinsic, metadata.Process(metadataRaw), specVersion)\n```\n\n#### Event Decode\n\n```\nmetadataRaw := \"\" // rpc state_getMetadata\nspecVersion := 0  // rpc chain_getRuntimeVersion\nevent = \"0x080000000000000080e36a09000000000200000001000000000000ca9a3b00000000020000\"\nsubstrate.DecodeEvent(event, metadataInstant, specVersion)\n```\n\n#### Log Decode\n\n```\nlogs := [\"0x054241424501014a7024ec6c4be378c35c254860d8f4ddc6f9d53ea8ce42ca00bc77c280511f1cb4c93fbd825e3c7dcabb36221372a9b5359c496e095d31afc359bdb9fac45487\"]\nsubstrate.DecodeLogDigest(logs)\n```\n\n#### Storage Decode\n\n```\nraw := \"0x2efb\"\nstorage.Decode(raw, \"i16\", nil)\n```\n\n### KeyRing\n\n#### Generate KeyPair\n\n```\nkeyRing := keyring.New(keyring.Sr25519Type, AliceSeed) // sr25519\nkeyRing := keyring.New(keyring.Ed25519Type, AliceSeed) // ed25519\n```\n\n#### Sign Message\n\n```\nkeyRing.Sign(\"hello world\") // sign utf-8 message\nkeyRing.Sign(\"0xffff\")      // sign hex message\n```\n\n### RPC\n\n#### Substrate RPC\n\nExample\n\n\u003e state_getMetadata\n\n```\nblockHash := \"\"\nrpc.GetMetadataByHash(conn, blockHash)\n```\n\n\u003e state_getStorage\n\n```\nvalidatorsRaw, err := rpc.ReadStorage(conn, \"Session\", \"Validators\", blockHash)\nvalidatorList := validatorsRaw.ToStringSlice()\n```\n\n#### Send Extrinsic\n\n```\n// set websocket endoint \nwebsocket.SetEndpoint(\"wss://shibuya-rpc.dwellir.com\")\n\nclient = \u0026rpc.Client{}\n\n// init latest metadata\nraw, err := GetMetadataByHash(nil)\nif err != nil {\n    panic(err)\n}\n\n// set metadata\nclient.SetMetadata(metadata.RegNewMetadataType(92, raw))\n\n// set sr25519 seed\nclient.SetKeyRing(keyring.New(keyring.Sr25519Type, AliceSeed))\n\n// sign transaction\nsignedTransaction, err := client.SignTransaction(\"Balances\", \"transfer\", map[string]interface{}{\"Id\": BobAccountId}, 12345)\n\n// send transaction async, will return block hash\nblockHash, err := client.SendAuthorSubmitAndWatchExtrinsic(signedTransaction)\n\n// send transaction synchronize, will return transaction hash\ntransactionHash, err := client.SendAuthorSubmitExtrinsic(signedTransaction)\n```\n\nMore information can be viewed https://polkadot.js.org/api/substrate/rpc.html\n\n## Contributions\n\nWe welcome contributions of any kind. Issues labeled can be good (first) contributions.\n\n## LICENSE\n\nApache-2.0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubscan-explorer%2Fsubstrate-api-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubscan-explorer%2Fsubstrate-api-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubscan-explorer%2Fsubstrate-api-rpc/lists"}