{"id":42254603,"url":"https://github.com/bandprotocol/band-std-reference-contracts-cosmwasm","last_synced_at":"2026-01-27T05:18:34.950Z","repository":{"id":95987790,"uuid":"520788961","full_name":"bandprotocol/band-std-reference-contracts-cosmwasm","owner":"bandprotocol","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-15T13:26:12.000Z","size":54,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-04-13T19:00:29.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/bandprotocol.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}},"created_at":"2022-08-03T07:58:24.000Z","updated_at":"2024-01-23T01:10:09.000Z","dependencies_parsed_at":"2023-04-14T13:46:50.869Z","dependency_job_id":"acd8a631-c0b7-4978-89ee-4ac099bb1b32","html_url":"https://github.com/bandprotocol/band-std-reference-contracts-cosmwasm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bandprotocol/band-std-reference-contracts-cosmwasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-cosmwasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-cosmwasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-cosmwasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-cosmwasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bandprotocol","download_url":"https://codeload.github.com/bandprotocol/band-std-reference-contracts-cosmwasm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-cosmwasm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-01-27T05:18:34.871Z","updated_at":"2026-01-27T05:18:34.945Z","avatar_url":"https://github.com/bandprotocol.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Band Protocol's Cosmwasm Standard Reference Contracts\n\n## Overview\n\nThis repository contains the CosmWasm code for Band Protocol's StdReference contracts. The live contract addresses can\nbe found in our [documentation](https://docs.bandchain.org/develop/supported-blockchains).\n\n## Build\n\n### Contract\n\nTo compile all contracts, run the following script in the repo root: `/scripts/build_artifacts.sh` or the command below:\nThe optimized wasm code and its checksums can be found in the `/artifacts` directory\n\n```\ndocker run --rm -v \"$(pwd)\":/code \\\n  --mount type=volume,source=\"$(basename \"$(pwd)\")_cache\",target=/code/target \\\n  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \\\n  cosmwasm/workspace-optimizer:0.12.7\n```\n\n### Schema\n\nTo generate the JSON schema files for the contract call, queries and query responses, run the following script in the\nrepo root: `/scripts/build_schemas.sh` or run `cargo schema` in the smart contract directory.\n\n## Usage\n\nTo query the prices from Band Protocol's StdReference contracts, the contract looking to use the price values should\nquery Band Protocol's `std_reference` contract.\n\n### QueryMsg\n\nThe query messages used to retrieve price data for price data are as follows:\n\n```rust\npub enum QueryMsg {\n    GetReferenceData {\n        // Symbol pair to query where:\n        // symbol_pair := (base_symbol, quote_symbol)\n        // e.g. BTC/USD ≡ (\"BTC\", \"USD\")\n        symbol_pair: (String, String),\n    },\n    GetReferenceDataBulk {\n        // Vector of Symbol pair to query\n        // e.g. \u003cBTC/USD ETH/USD, BAND/BTC\u003e ≡ \u003c(\"BTC\", \"USD\"), (\"ETH\", \"USD\"), (\"BAND\", \"BTC\")\u003e\n        symbol_pairs: Vec\u003c(String, String)\u003e,\n    },\n}\n```\n\n### ReferenceData\n\n`ReferenceData` is the struct that is returned when querying with `GetReferenceData` or `GetReferenceDataBulk` where the\nbulk variant returns `Vec\u003cReferenceData\u003e`\n\n`ReferenceData` is defined as:\n\n```rust\npub struct ReferenceData {\n    // Pair rate e.g. rate of BTC/USD\n    pub rate: Uint256,\n    // Unix time of when the base asset was last updated. e.g. Last update time of BTC in Unix time\n    pub last_updated_base: Uint64,\n    // Unix time of when the quote asset was last updated. e.g. Last update time of USD in Unix time\n    pub last_updated_quote: Uint64,\n}\n```\n\n### Examples\n\n#### Single Query\n\nFor example, if we wanted to query the price of `BTC/USD`, the demo function below shows how this can be done.\n\n```rust\nfn demo(\n    std_ref_addr: Addr,\n    symbol_pair: (String, String),\n) -\u003e StdResult\u003cReferenceData\u003e {\n    deps.querier.query_wasm_smart(\n        \u0026std_ref_addr,\n        \u0026QueryMsg::GetReferenceData {\n            symbol_pair,\n        },\n    )\n}\n```\n\nWhere the result from `demo(std_ref_addr, (\"BTC\", \"USD\"))` would yield:\n\n```\nReferenceData(23131270000000000000000, 1659588229, 1659589497)\n```\n\nand the results can be interpreted as:\n\n- BTC/USD\n    - `rate = 23131.27 BTC/USD`\n    - `lastUpdatedBase = 1659588229`\n    - `lastUpdatedQuote = 1659589497`\n\n#### Bulk Query\n\n```rust\nfn demo(\n    std_ref_addr: Addr,\n    symbol_pairs: Vec\u003cString\u003e,\n) -\u003e StdResult\u003cReferenceData\u003e {\n    deps.querier.query_wasm_smart(\n        \u0026std_ref_addr,\n        \u0026QueryMsg::GetReferenceDataBulk {\n            symbol_pairs,\n        },\n    )\n}\n```\n\nWhere the result from `demo(std_ref_addr, [(\"BTC\", \"USD\"), (\"ETH\", \"BTC\")])` would yield:\n\n```\n[\n    ReferenceData(23131270000000000000000, 1659588229, 1659589497),\n    ReferenceData(71601775432131482, 1659588229, 1659588229)\n]\n```\n\nand the results can be interpreted as:\n\n- BTC/USD\n    - `rate = 23131.27 BTC/USD`\n    - `lastUpdatedBase = 1659588229`\n    - `lastUpdatedQuote = 1659589497`\n- ETH/BTC\n    - `rate = 0.07160177543213148 ETH/BTC`\n    - `lastUpdatedBase = 1659588229`\n    - `lastUpdatedQuote = 1659588229`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbandprotocol%2Fband-std-reference-contracts-cosmwasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbandprotocol%2Fband-std-reference-contracts-cosmwasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbandprotocol%2Fband-std-reference-contracts-cosmwasm/lists"}