{"id":42254607,"url":"https://github.com/bandprotocol/band-std-reference-contracts-ink","last_synced_at":"2026-01-27T05:18:35.711Z","repository":{"id":215405601,"uuid":"683973577","full_name":"bandprotocol/band-std-reference-contracts-ink","owner":"bandprotocol","description":"A Rust implementation of Band Protocol's ink! Standard Reference smart contract","archived":false,"fork":false,"pushed_at":"2024-06-14T09:13:17.000Z","size":2024,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-06-15T08:49:15.093Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-28T07:18:20.000Z","updated_at":"2024-06-14T09:13:21.000Z","dependencies_parsed_at":"2024-01-22T17:38:58.438Z","dependency_job_id":"b218a6ae-2e41-4fed-9c14-282495363b5b","html_url":"https://github.com/bandprotocol/band-std-reference-contracts-ink","commit_stats":null,"previous_names":["bandprotocol/band-std-reference-contracts-ink"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bandprotocol/band-std-reference-contracts-ink","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-ink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-ink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-ink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-ink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bandprotocol","download_url":"https://codeload.github.com/bandprotocol/band-std-reference-contracts-ink/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bandprotocol%2Fband-std-reference-contracts-ink/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:35.108Z","updated_at":"2026-01-27T05:18:35.706Z","avatar_url":"https://github.com/bandprotocol.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Band Protocol's ink! Standard Reference Contracts\n\n## Overview\n\nThis repository contains the ink! 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### Contract Compilation\n\n#### Option 1: Using Docker\n\nTo compile the Standard Reference Contract on Intel architecture, use the following command:\n\n```bash\ncd /contracts/std_ref\n\ndocker run --rm -it -v $(pwd):/contracts/std_ref paritytech/contracts-ci-linux \\\n  cargo contract build --release --manifest-path=/contracts/std_ref/Cargo.toml\n```\n\nTo compile on M1 architecture, use the following command:\n\n```bash\ncd /contracts/std_ref\n\ndocker run --rm -it -v $(pwd):/contracts/std_ref --platform linux/amd64 paritytech/contracts-ci-linux \\\n  cargo contract build --release --manifest-path=/contracts/std_ref/Cargo.toml\n```\n\n#### Option 2: Using Cargo Contract (Recommended)\n\nTo compile the Standard Reference Contract, you'll need to use cargo-contract, a tool for working with smart contracts in the Rust programming language.\n\n1. Install Cargo contract\n\n   - Step 1: `rustup component add rust-src`.\n   - Step 2: `cargo install --force --locked cargo-contract`.\n\n2. Run the build command. For contracts intended to run in production, you should always build the contract with --release:\n\n   ```bash\n   cargo contract build --release\n   ```\n\n## Usage\n\nTo query the prices from Band Protocol's StdReference contracts, the contract looking to use the price values should query 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\u003e = \u003c(\"BTC\",\"USD\"),(\"ETH\",\"USD\")\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: u128,\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: u64,\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: u64,\n}\n```\n\n## Examples\n\n### Using the Contracts UI\n\nThis example use [StdReferenceBasic contract](https://shibuya.subscan.io/account/YhesbtnjHC7srVHN2f69vQiRwwLNYBTuUN15Z5NJzygimrF) on Astar Shibuya.\n\nFollow these steps:\n\n1. Navigate to https://contracts-ui.substrate.io/address-lookup\n2. Paste the contract address `YhesbtnjHC7srVHN2f69vQiRwwLNYBTuUN15Z5NJzygimrF`\n3. Modify the contract's name\n4. upload metadata from `band-std-reference-contracts-ink/contracts/std_ref/metadata/standard_reference.json`\n5. You can now interact with the contract\n\n#### Single Query\n\nThis example demonstrates how to query the price of cryptocurrencies, such as BTC/USD and ETH/USD, using the get_reference_data function.\n\n![get_reference_data](img/get_reference_data.png)\n\nThe result from the `get_reference_data` function\n\n```text\n{\n  Ok: {\n    rate: '42,796,574,079,000,000,000,000',\n    baseResolveTime: '1,705,393,635',\n    quoteResolveTime: '1,705,566,198',\n  },\n}\n```\n\nand the results can be interpreted as:\n\n- BTC/USD\n  - `rate = 42796.57 BTC/USD`\n  - `lastUpdatedBase = 1705393635`\n  - `lastUpdatedQuote = 1705566198`\n\n#### Bulk Query\n\nThis example demonstrates how to perform bulk queries for multiple cryptocurrency pairs using the get_reference_data_bulk function.\n\n![get_reference_data_bulk](/img/get_reference_data_bulk.png)\n\nThe result from the `get_reference_data_bulk` function\n\n```text\n[\n  {\n    Ok: {\n      rate: '42,796,574,079,000,000,000,000',\n      baseResolveTime: '1,705,393,635',\n      quoteResolveTime: '1,705,566,390',\n    },\n  },\n  {\n    Ok: {\n      rate: '2,529,382,050,297,000,000,000',\n      baseResolveTime: '1,705,393,635',\n      quoteResolveTime: '1,705,566,390',\n    },\n  },\n]\n```\n\nand the results can be interpreted as:\n\n- BTC/USD\n  - `rate = 42796.57 BTC/USD`\n  - `lastUpdatedBase = 1705393635`\n  - `lastUpdatedQuote = 1705566198`\n- ETH/USD\n  - `rate = 2529.38 ETH/USD`\n  - `lastUpdatedBase = 1705393635`\n  - `lastUpdatedQuote = 1705566198`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbandprotocol%2Fband-std-reference-contracts-ink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbandprotocol%2Fband-std-reference-contracts-ink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbandprotocol%2Fband-std-reference-contracts-ink/lists"}