diff --git a/.github/workflows/chain-docs.yml b/.github/workflows/chain-docs.yml index e07d049d..bf968747 100644 --- a/.github/workflows/chain-docs.yml +++ b/.github/workflows/chain-docs.yml @@ -2,7 +2,7 @@ name: chain-docs on: push: - branches: [ master ] + branches: [master] issue_comment: types: [created] jobs: @@ -11,24 +11,21 @@ jobs: runs-on: ubuntu-22.04 if: >- github.event_name == 'push' || github.event_name == 'pull_request' || (github.event.comment.body == '/staging' && - (github.actor == 'allthatjazzleo' || github.actor == 'tomtau' || github.actor == 'lezzokafka' || github.actor == 'yihuang' || - github.actor == 'calvinaco' || github.actor == 'CeruleanAtMonaco' || github.actor == 'devashishdxt' || - github.actor == 'leejw51crypto' || github.actor == 'cdc-Hitesh' || github.actor == 'eddycpc' || github.actor == 'crypto-matto' || - github.actor == 'borischeuk-crypto' || github.actor == 'mofhusseini' || github.actor == 'cdc-william' || github.actor == 'ysong42')) + (github.actor == 'allthatjazzleo' || github.actor == 'lezzokafka'|| github.actor == 'aw126')) steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Perform ShiftLeft Scan - uses: ShiftLeftSecurity/scan-action@master - env: - WORKSPACE: "" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SCAN_AUTO_BUILD: true - with: - output: reports - # Scan auto-detects the languages in your project. To override uncomment the below variable and set the type - # type: credscan,java - # type: python + - name: Checkout + uses: actions/checkout@v2 + - name: Perform ShiftLeft Scan + uses: ShiftLeftSecurity/scan-action@master + env: + WORKSPACE: "" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SCAN_AUTO_BUILD: true + with: + output: reports + # Scan auto-detects the languages in your project. To override uncomment the below variable and set the type + # type: credscan,java + # type: python # - name: Upload report # uses: github/codeql-action/upload-sarif@v1 # with: @@ -38,53 +35,49 @@ jobs: runs-on: ubuntu-22.04 needs: scan if: >- - github.event_name == 'push' || (github.event.comment.body == '/staging' && (github.actor == 'allthatjazzleo' || github.actor == 'tomtau' || - github.actor == 'lezzokafka' || github.actor == 'yihuang' || github.actor == 'calvinaco' || - github.actor == 'CeruleanAtMonaco' || github.actor == 'devashishdxt' || github.actor == 'leejw51crypto' || - github.actor == 'cdc-Hitesh' || github.actor == 'eddycpc' || github.actor == 'crypto-matto' || - github.actor == 'borischeuk-crypto' || github.actor == 'mofhusseini' || github.actor == 'cdc-william' || github.actor == 'ysong42')) + github.event_name == 'push' || (github.event.comment.body == '/staging' && (github.actor == 'allthatjazzleo' || github.actor == 'lezzokafka'|| github.actor == 'aw126')) steps: - - name: Github API Request - id: request - uses: octokit/request-action@v2.0.0 - if: github.event_name == 'issue_comment' - with: - route: ${{ github.event.issue.pull_request.url }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Get PR informations - id: pr_data - if: github.event_name == 'issue_comment' - run: | - echo "::set-output name=branch::${{ fromJson(steps.request.outputs.data).head.ref }}" - echo "::set-output name=repo_name::${{ fromJson(steps.request.outputs.data).head.repo.full_name }}" - - name: Checkout PR Branch - uses: actions/checkout@v2 - if: github.event_name == 'issue_comment' - with: - token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ steps.pr_data.outputs.repo_name }} - ref: ${{ steps.pr_data.outputs.branch }} - - name: Check MASTER code - uses: actions/checkout@v2 - if: github.event_name == 'push' - - uses: actions/setup-node@v1 - with: - node-version: '12' - - name: ci - env: - MASTER_AWS_ACCESS_KEY_ID: ${{ secrets.MASTER_AWS_ACCESS_KEY_ID }} - MASTER_AWS_SECRET_ACCESS_KEY: ${{ secrets.MASTER_AWS_SECRET_ACCESS_KEY }} - MASTER_BUCKET_NAME: ${{ secrets.MASTER_BUCKET_NAME }} - MASTER_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.MASTER_CLOUDFRONT_DISTRIBUTION_ID }} - MASTER_REGION: ${{ secrets.MASTER_REGION }} - EVENT: ${{ github.event_name }} - STAGING_AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} - STAGING_AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} - STAGING_BUCKET_NAME: ${{ secrets.STAGING_BUCKET_NAME }} - STAGING_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }} - STAGING_REGION: ${{ secrets.STAGING_REGION }} - run: | - . ci/scripts/prepare - ci/scripts/build - ci/scripts/deploy + - name: Github API Request + id: request + uses: octokit/request-action@v2.0.0 + if: github.event_name == 'issue_comment' + with: + route: ${{ github.event.issue.pull_request.url }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get PR informations + id: pr_data + if: github.event_name == 'issue_comment' + run: | + echo "::set-output name=branch::${{ fromJson(steps.request.outputs.data).head.ref }}" + echo "::set-output name=repo_name::${{ fromJson(steps.request.outputs.data).head.repo.full_name }}" + - name: Checkout PR Branch + uses: actions/checkout@v2 + if: github.event_name == 'issue_comment' + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ steps.pr_data.outputs.repo_name }} + ref: ${{ steps.pr_data.outputs.branch }} + - name: Check MASTER code + uses: actions/checkout@v2 + if: github.event_name == 'push' + - uses: actions/setup-node@v1 + with: + node-version: "12" + - name: ci + env: + MASTER_AWS_ACCESS_KEY_ID: ${{ secrets.MASTER_AWS_ACCESS_KEY_ID }} + MASTER_AWS_SECRET_ACCESS_KEY: ${{ secrets.MASTER_AWS_SECRET_ACCESS_KEY }} + MASTER_BUCKET_NAME: ${{ secrets.MASTER_BUCKET_NAME }} + MASTER_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.MASTER_CLOUDFRONT_DISTRIBUTION_ID }} + MASTER_REGION: ${{ secrets.MASTER_REGION }} + EVENT: ${{ github.event_name }} + STAGING_AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} + STAGING_AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} + STAGING_BUCKET_NAME: ${{ secrets.STAGING_BUCKET_NAME }} + STAGING_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }} + STAGING_REGION: ${{ secrets.STAGING_REGION }} + run: | + . ci/scripts/prepare + ci/scripts/build + ci/scripts/deploy diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 742d768a..4e0350f4 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -31,11 +31,15 @@ module.exports = { { text: "Cronos Gravity bridge Testnet", link: "/getting-started/cronos-gbtestnet" - }, + }, { text: "Local network deployment", link: "/getting-started/local-devnet" }, + { + text: "Cronos node setup best practises", + link: "/getting-started/cronos-node-best-practises" + }, { text: "Deploy Smart Contract at Cronos", link: "/getting-started/cronos-smart-contract" @@ -90,7 +94,11 @@ module.exports = { { text: "From other chains (Crypto.com DeFi Desktop Wallet)", link: "/bridge/other_chain#via-crypto-com-defi-desktop-wallet" - } + }, + { + text: "Gravity Bridge (Cronos Bridge WebApp - Testnet only)", + link: "/bridge/gb-testnet" + } ] }, { @@ -137,7 +145,11 @@ module.exports = { { text: "Technical Glossary", link: "/resources/technical-glossary" - } + }, + { + text: "Useful Projects on Cronos", + link: "/resources/useful-projects" + }, ] } ], @@ -146,8 +158,9 @@ module.exports = { "cronos-mainnet", "metamask", "cronos-testnet", - "cronos-gbtesnet", + "cronos-gbtestnet", "local-devnet", + "cronos-node-best-practises", "security-checklist.md", "defi-practice", "cronos-smart-contract" @@ -166,7 +179,8 @@ module.exports = { ], "/bridge/": [ "app_n_ex", - "other_chain" + "other_chain", + "gb-testnet" ], "/play/": [ "introduction", @@ -180,7 +194,8 @@ module.exports = { "desktop-wallet-integration", "node-and-rpc-setup-notes", "cosmos-grpc-docs", - "technical-glossary" + "technical-glossary", + "useful-projects", ], "/api/": "auto" }, diff --git a/docs/bridge/assets/Uniswap.png b/docs/bridge/assets/Uniswap.png new file mode 100644 index 00000000..bc3a0492 Binary files /dev/null and b/docs/bridge/assets/Uniswap.png differ diff --git a/docs/bridge/assets/Uniswaptoken.png b/docs/bridge/assets/Uniswaptoken.png new file mode 100644 index 00000000..3f2bec4f Binary files /dev/null and b/docs/bridge/assets/Uniswaptoken.png differ diff --git a/docs/bridge/assets/Uniswaptokenconfirm.png b/docs/bridge/assets/Uniswaptokenconfirm.png new file mode 100644 index 00000000..90b679ef Binary files /dev/null and b/docs/bridge/assets/Uniswaptokenconfirm.png differ diff --git a/docs/bridge/assets/Uniswaptokenimport.png b/docs/bridge/assets/Uniswaptokenimport.png new file mode 100644 index 00000000..29c79828 Binary files /dev/null and b/docs/bridge/assets/Uniswaptokenimport.png differ diff --git a/docs/bridge/assets/bridge.png b/docs/bridge/assets/bridge.png new file mode 100644 index 00000000..34b612a1 Binary files /dev/null and b/docs/bridge/assets/bridge.png differ diff --git a/docs/bridge/assets/bridgingcompleted.png b/docs/bridge/assets/bridgingcompleted.png new file mode 100644 index 00000000..4ddbf1f4 Binary files /dev/null and b/docs/bridge/assets/bridgingcompleted.png differ diff --git a/docs/bridge/assets/bridginghistory.png b/docs/bridge/assets/bridginghistory.png new file mode 100644 index 00000000..2f2d5895 Binary files /dev/null and b/docs/bridge/assets/bridginghistory.png differ diff --git a/docs/bridge/assets/bridgingpending.png b/docs/bridge/assets/bridgingpending.png new file mode 100644 index 00000000..40897acb Binary files /dev/null and b/docs/bridge/assets/bridgingpending.png differ diff --git a/docs/bridge/assets/confirmmetamask.png b/docs/bridge/assets/confirmmetamask.png new file mode 100644 index 00000000..ee997177 Binary files /dev/null and b/docs/bridge/assets/confirmmetamask.png differ diff --git a/docs/bridge/assets/confirmpioneer.png b/docs/bridge/assets/confirmpioneer.png new file mode 100644 index 00000000..02a116db Binary files /dev/null and b/docs/bridge/assets/confirmpioneer.png differ diff --git a/docs/bridge/assets/enablecontract.png b/docs/bridge/assets/enablecontract.png new file mode 100644 index 00000000..df28ce49 Binary files /dev/null and b/docs/bridge/assets/enablecontract.png differ diff --git a/docs/bridge/assets/metamaskpioneer11.png b/docs/bridge/assets/metamaskpioneer11.png new file mode 100644 index 00000000..90e6496d Binary files /dev/null and b/docs/bridge/assets/metamaskpioneer11.png differ diff --git a/docs/bridge/assets/pioneerassets.png b/docs/bridge/assets/pioneerassets.png new file mode 100644 index 00000000..786c8301 Binary files /dev/null and b/docs/bridge/assets/pioneerassets.png differ diff --git a/docs/bridge/assets/testnetworks.png b/docs/bridge/assets/testnetworks.png new file mode 100644 index 00000000..5cefd266 Binary files /dev/null and b/docs/bridge/assets/testnetworks.png differ diff --git a/docs/bridge/assets/transferassets1.png b/docs/bridge/assets/transferassets1.png new file mode 100644 index 00000000..ea276703 Binary files /dev/null and b/docs/bridge/assets/transferassets1.png differ diff --git a/docs/bridge/assets/transferassets2.png b/docs/bridge/assets/transferassets2.png new file mode 100644 index 00000000..a2848ed4 Binary files /dev/null and b/docs/bridge/assets/transferassets2.png differ diff --git a/docs/bridge/assets/webapp_connect_wallet_pioneer.png b/docs/bridge/assets/webapp_connect_wallet_pioneer.png new file mode 100644 index 00000000..c34ff525 Binary files /dev/null and b/docs/bridge/assets/webapp_connect_wallet_pioneer.png differ diff --git a/docs/bridge/gb-testnet.md b/docs/bridge/gb-testnet.md new file mode 100644 index 00000000..89a8113a --- /dev/null +++ b/docs/bridge/gb-testnet.md @@ -0,0 +1,153 @@ +# Via the Gravity Bridge Web App - Testnet only + +## Transfer assets between Ethereum testnet and Cronos testnet using the Gravity Bridge Web App + +### Introduction + +::: danger Risk and disclaimer +Please read the guide carefully and review the project documentation as misuse may cause incorrect transfer or even loss of assets. We recommend transferring a small amount first to get yourself acquainted with the bridge before moving significant amounts. We are **NOT** responsible for any losses incurred while using the bridge! Use at your own risk. +::: + +centered image + +The Gravity Bridge now makes it possible to transfer assets between the Cronos and the Ethereum network. The Gravity Bridge (Beta) for Testnet can be found [here](https://cronos.org/bridge/). Make sure to switch to the Testnet. + +The Gravity Bridge is derived from a Cosmos community open-source project, called [PeggyJV gravity bridge](https://github.com/PeggyJV/gravity-bridge). The gravity bridge technology allows the transfer of ERC20 cryptocurrency tokens from and to Ethereum through a mint/lock mechanism. + +This means that: +When a user sends assets from Ethereum to Cronos, the corresponding ERC20 token is locked in a smart contract on the Ethereum side, and minted on the Cronos side in the form of a CRC20 token. +When a user sends assets from Cronos to Ethereum, the corresponding CRC20 token is burned on the Cronos side, and the ERC20 token is released on the Ethereum side. + + +#### Currently supported tokens from [Goerli Testnet]: +- WETH +- WBTC +- USDC +- USDT +- DAI + +| ERC20 | Goerli | Pioneer11 | +| ------|------------------------------------------- | ------------------------------------------ | +| USDC | 0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C | 0x8a8DfedBF6650737DFf63c2f455ecC54AcEcF197 | +| WETH | 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 | 0x17774909725bA203B8501C1DEb22F2495584197e | +| USDT | 0xe802376580c10fE23F027e1E19Ed9D54d4C9311e | 0xA5e7cD85b15586ecb8DA34AcEE42FF83ABcB555b | +| WBTC | 0xC04B0d3107736C32e19F1c62b2aF67BE61d63a05 | 0x7825cB7feEAD896241f748c89550F3D01AF51e48 | +| DAI | 0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60 | 0x71339a9C403383c3E18712130615d369Ff9a7124 | + + +#### Currently supported wallets: +- Metamask +- Crypto.com DeFi Wallet + +We are constantly working on adding new tokens and chain support. If you have any feedback and issues, please drop us an email at product.bridge@crypto.org. + +### How to use the Gravity Bridge [Web Dapp] + +#### 1. Connect your wallet +Click the “Connect Wallet" button on the top right to connect your browser extension wallet. Choose one of the supported wallets and look for a popup from your wallet interface or click into the wallet extension to give consent. Note that it might already ask permission to switch network, press "Accept" in that case. + +centered image + + **Testnet** +If you are using Metamask, make sure to enable test networks, on the Metamask wallet +Go to settings > Advanced > enable `Show test networks`. Now you should be able to select the Goerli Test Network in the list of networks, which we will be using in this tutorial. + +For the Pioneer11 testnet, Go to settings > Networks > Add network +Add the following network details: + +- Network Name: **Pioneer11** +- New RPC URL: **https://evm-p11.cronos.org** +- ChainID: **340** +- Currency symbol: **TCRO** +- Block Explorer URL (Optional): **https://cronos.org/explorer/pioneer11** + +centered image +centered image + +#### 2. Select Network and Token +Select the origin chain on the left and the destination chain on the right in the bridge interface. Auto-suggestion may set some parameters. However, a manual check might be needed to match your wallet settings to the selected network. Once the networks are chosen, select the asset you would like to transfer. +Note that your ERC20 compatible addresses on Ethereum and Cronos are the same. + + +centered image + + +If you would like to swap any of the other tokens listed, you can head to [Uniswap](https://app.uniswap.org/#/swap?chain=goerli) on Goerli testnet. Refer to [Swap tokens on Uniswap](#swap-tokens-on-uniswap) for an example. + +#### 3. Enter the amount +After selecting the network and token, enter and confirm the amount you would like to transfer. +The bridge network fees will be calculated accordingly. You always need to pay the gas fee charged by the source network. Before bridging a large amount, we encourage testing a transfer of a minor amount first to ensure all the settings are correct. + +If this is the first time you are swapping this particular token using the Gravity Bridge, you may need to enable the contract such that the Gravity Bridge has access to this token. For example for USDC, click the "enable" button and accept permission in your wallet. Now you can bridge UDSC. + + +centered image + + +**From Ethereum (Goerli testnet) to Cronos Gravity Bridge testnet** + +Note that there might be additional bridge network fees calculated. During the promotional launch period, the network fee incurred by the bridge from Ethereum to Cronos will be waived. + +For Goerli, you can get some Goerli Eth from one of the Goerli faucets, for example: +- [https://faucets.chain.link/goerli](https://faucets.chain.link/goerli) +- [https://goerlifaucet.com/](https://goerlifaucet.com/) +- check the goerli testnet page for other faucets [https://github.com/eth-clients/goerli](https://github.com/eth-clients/goerli). + +centered image + +**From Cronos Gravity Bridge testnet to Ethereum (Goerli testnet)** + +Note that there might be additional bridge network fees calculated. When bridging from Cronos to Ethereum, you will have two options for bridging, Cronos Pool and Cronos Warp. +- Cronos Pool are batched transfers which range from ~5 mins up to 12 hours. +- Cronos Warp are immediate transfers ranging from ~few mins to 1 hour. + +For Pioneer 11, you can get some TCRO from the [pioneer 11 faucet](https://cronos.org/pioneer11-faucet) + +centered image + + +#### 4. Confirm the transaction +Once all transfer settings have been confirmed, click "Transfer Assets", a transaction confirmation page will pop up summarizing the transaction. This will send a transaction request to your wallet; please confirm on your wallet screen to ultimately authorize the transfer. + +Please note that after bridging the tokens, they will be converted into the destination blockchain-supported tokens. + +centered image + +centered image + + +#### 5. Bridging assets +After the transaction is confirmed from the wallet, the bridge operation will commence. First, we will initiate and wait for the deposit of the assets on the origin chain. Once the deposit is confirmed, we will initiate the transfer in the destination chain to your desired receiving wallet address. Both transactions will include an external link to view and monitor the transaction on-chain via explorers such as Cronoscan and Etherscan. + +Even if you dismiss, quit, or refresh the page, a small popup reminder will be available to indicate an in-progress transaction. A “transfer completed” message will finally confirm that the transaction has been completed successfully. You can see a full record of past transactions tied to your wallet in the History tab. + +Thank you for using the Cronos bridge and supporting the Cronos Ecosystem! + + +centered image + + +centered image + + +### Appendix + +## Swap tokens on Uniswap + +Head to [Uniswap](https://app.uniswap.org/#/swap?chain=goerli) on Goerli testnet. Connect with your wallet and switch to the goerli network. + +centered image + + +If the token you are looking to swap to is not listed, you may need to import the token address yourself, for example for [USDC](https://goerli.etherscan.io/address/0xD87Ba7A50B2E7E660f678A895E4B72E7CB4CCd9C) on Goerli testnet: + +centered image + + +Make sure that this is the correct address for your token before importing! If so, click "import" and finally, confirm the swap. + + +centered image +centered image + + diff --git a/docs/getting-started/cronos-gbtesnet.md b/docs/getting-started/cronos-gbtestnet.md similarity index 100% rename from docs/getting-started/cronos-gbtesnet.md rename to docs/getting-started/cronos-gbtestnet.md diff --git a/docs/getting-started/cronos-node-best-practises.md b/docs/getting-started/cronos-node-best-practises.md new file mode 100644 index 00000000..e0b1fdb6 --- /dev/null +++ b/docs/getting-started/cronos-node-best-practises.md @@ -0,0 +1,32 @@ +# Best Practices for node hosts in Cronos + +In order to make it more convenient for Dapps and node hosts to setup a node, we put together a list of useful settings and configurations. Feel free to refer to this guide, and adapt settings to suit your use-case. + +## config.toml + +### Log_level +- `info` Depending on the needs of your application it is ok to stick to `info` (default), but do consider setting up log-rotation for your logs, and archive logs after a certain amount of time or size, e.g. use a cron job with weekly rotation or until your file size hits ~5GB. +- set to `debug` only for debugging purpose, turn off after you are finished with debugging. + +### db_backend +- `goleveldb` (default) db: for low / medium level traffic use case. The reason being there can be some lock contention, especially with P2P. +- `rocksdb` suited for a lot of use-cases, especially for high query load ~ few M / day. Has a better balance between rpc queries and p2p at high traffic. Note that`Rocksdb` however might have a slower startup time and requires a higher memory allocation. + +### max_num_inbound_peers and max_num_outbound_peers +- `max_num_inbound_peers` For node providers the number of inbound peers can be set to a higher value for example 50. +- `max_num_outbound_peers` For users on a private network set a higher number of outbound peers to 30 for example. +- After peers are connected, set it back to its default value. Note that some trial values might be needed to get it right. + + +## app.toml + +### pruning +- `default` Normal usage can just set to default. In the Cosmos SDK this is defined as: +```go +PruneDefault = NewPruningOptions(362880, 100, 10) +``` +meaning the app will keep the latest 362880 versions (around 21 days by 5 secs block time), and then only keep 1 version for every 100 blocks past the keepRecent period( the rest will be put into the pruning list), and then execute the pruning every 10 blocks. +- `everything` if you only need to do transaction broadcasting and only need the last blocks. +- `nothing` for DApps that want to be able to query information at a certain known blockheight. Note that this is only needed for `archive` nodes. + + diff --git a/docs/resources/useful-projects.md b/docs/resources/useful-projects.md new file mode 100644 index 00000000..5102965c --- /dev/null +++ b/docs/resources/useful-projects.md @@ -0,0 +1,154 @@ +# Useful Projects on Cronos + + +## Band Protocol's Data Feed + +### Introduction + +**Band Protocol** is a secure, blockchain-agnostic decentralized oracle solution ([more detail here](https://docs.bandchain.org)). +It features a blockchain of its own (**BandChain**) that does the heavy-lifting job of pulling data from external sources, +aggregating all the results, and creating a verifiable proof of data integrity to be used in other blockchain +applications — all with a secure crypto-economic which guarantees data availability and correctness. + +Developers building applications on **Cronos** can now utilize **Band**’s decentralized oracle services. +With **Band**’s oracle, they now have access to various cryptocurrency price data to integrate into their applications. + +### Currency Pair and Supported Currencies + +A currency pair is the quotation of two different currencies, with the value of one currency being quoted against the other. +The first listed currency of a currency pair is the _base currency_, and the second currency is called the _quote currency_. +A currency pair compares the value of one currency to another — the _base currency_ versus the _quote currency_. +It indicates how much one unit of the _base currency_ worths in the unit of the _quote currency_, +or, in other words, how much of the _quote currency_ is needed to purchase one unit of the _base currency_. +For instance, in a currency pair `CRO/USD`, `CRO` is the cryptocurrency **Cronos** as the _base currency_, +and `USD` is the fiat currency **U.S. Dollar** as the _quote currency_. +The value of currency pair `CRO/USD` will indicate how much one `CRO` worths in **U.S. Dollar**. + +Currently, one fiat currency - the **U.S. Dollar** - and the following list of cryptocurrencies are supported. +Going forward, this token list will continue to expand based on developers' needs and community feedback. + +| Token Name | Symbol | +|-----------------| ------ | +| Cronos | CRO | +| Ethereum | ETH | +| Wrapped Bitcoin | WBTC | +| Tether | USDT | +| USD Coin | USDC | +| Dai | DAI | + +### Price Queries + +Developers are able to query token prices from **Band**’s oracle through **Band**’s +`StdReferenceProxy` contract on **Cronos Chain**. +This contract exposes `getReferenceData` and `getReferenceDataBulk` functions, +to query one currency pair and multiple currency pairs, respectively. + +`getReferenceData` takes two strings as the inputs — the _base_ and _quote_ symbols respectively. +It then queries the `StdReference` contract for the latest rate of the specified currency pair, _base_ against _quote_. +The query returns a `ReferenceData` struct, shown below: +```solidity +struct ReferenceData { + uint256 rate; // base/quote exchange rate, multiplied by 1e18. + uint256 lastUpdatedBase; // UNIX epoch of the last time when base price gets updated. + uint256 lastUpdatedQuote; // UNIX epoch of the last time when quote price gets updated. +} +``` + +`getReferenceDataBulk` instead takes two lists as inputs: one for the _base currencies_, and one for the _quote currencies_. +It then proceeds to query the rate for each _base_/_quote_ pair at each index, +and returns an array of `ReferenceData` structs. + +For example, if we call `getReferenceDataBulk(['CRO','WBTC','ETH'], ['USD','ETH','DAI'])`, the returned `ReferenceData` +array will contain information regarding the following currency pairs: + +- `CRO/USD` +- `WBTC/ETH` +- `ETH/DAI` + +### Example Usage + +The contract code below demonstrates a simple example usage of **Band**'s `StdReferenceProxy` contract +and its `getReferenceData` and `getReferenceDataBulk` functions. + +```solidity +pragma solidity ^0.8.13; + +interface IStdReference { + /// A structure returned whenever someone requests for standard reference data. + struct ReferenceData { + uint256 rate; // base/quote exchange rate, multiplied by 1e18. + uint256 lastUpdatedBase; // UNIX epoch of the last time when base price gets updated. + uint256 lastUpdatedQuote; // UNIX epoch of the last time when quote price gets updated. + } + + /// Returns the price data for the given base/quote pair. Revert if not available. + function getReferenceData(string memory _base, string memory _quote) + external + view + returns (ReferenceData memory); + + /// Similar to getReferenceData, but with multiple base/quote pairs at once. + function getReferenceDataBulk(string[] memory _bases, string[] memory _quotes) + external + view + returns (ReferenceData[] memory); +} + +contract DemoOracleUSD { + IStdReference ref; + + string[] public tokenList = ["CRO", "ETH", "WBTC", "USDT", "USDC", "DAI"]; + mapping(string => uint256) public lastPricesInUSD; + + modifier onlySupportedToken(string memory _token) { + bool supported = false; + for (uint i=0; i/` in this case) by `cd..`. Then run Cronos again with `./cronosd start` and now it suppose to start the node and sync the blockchain data from the height of `1813707`. +:::details Example: Restart `cronosd start` with QuickSync {% hint style="info" %} Example: Restart `chain-maind start` with QuickSync diff --git a/package-lock.json b/package-lock.json index 93cebd56..a092ac87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3401,13 +3401,19 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001246", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001246.tgz", - "integrity": "sha512-Tc+ff0Co/nFNbLOrziBXmMVtpt9S2c2Y+Z9Nk9Khj09J+0zR9ejvIW5qkZAErCbOrVODCx/MN+GpB5FNBs5GFA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - } + "version": "1.0.30001363", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001363.tgz", + "integrity": "sha512-HpQhpzTGGPVMnCjIomjt+jvyUu8vNFo3TaDiZ/RcoTrlOq/5+tC8zHdsbgFB6MxmaY+jCpsH09aD80Bb4Ow3Sg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] }, "node_modules/caseless": { "version": "0.12.0", @@ -15399,9 +15405,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001246", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001246.tgz", - "integrity": "sha512-Tc+ff0Co/nFNbLOrziBXmMVtpt9S2c2Y+Z9Nk9Khj09J+0zR9ejvIW5qkZAErCbOrVODCx/MN+GpB5FNBs5GFA==" + "version": "1.0.30001363", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001363.tgz", + "integrity": "sha512-HpQhpzTGGPVMnCjIomjt+jvyUu8vNFo3TaDiZ/RcoTrlOq/5+tC8zHdsbgFB6MxmaY+jCpsH09aD80Bb4Ow3Sg==" }, "caseless": { "version": "0.12.0",