Chains

BNB Smart Chain

Build Web3 dApps effortlessly

BNB Beacon Chain

Sunset soon

BNB Chain ecosystem’s staking & governance layer

DocumentationGitHubFaucetStake BNBBscScanBSCTraceDev ToolsLearn more about FusionDocumentationBeacon Chain ExplorerStake BNBDocumentationGitHubFaucetBridgeGreenfieldScanDCellarDev ToolsDocumentationGitHubFaucetBridgeopBNBScanDev ToolsDocumentationGitHub

Developers

Developers

Start building on BNB Chain

Start Building
Developers
BNB Smart ChainBNB GreenfieldopBNBzkBNBTrading Volume Incentive ProgramDAU Incentive ProgramTVL Incentive ProgramKickstartMVB Accelerator ProgramBuilder GrantsSpace BMEME Innovation ProgramSee All Programs
Contact UsStart Building
Contact UsStart Building

Binance Smart Chain Completes Integration With Band Protocol To Bolster Scalable Decentralized Applications

2020.8.19  •  13 min read
Blog post image.

Binance Smart Chain has partnered with Band Protocol, a cross-chain data oracle platform that aggregates and connects real-world data and APIs to smart contracts, to bring Band Protocol’s decentralized and customizable oracles to Binance Smart Chain’s ecosystem and open a gateway for truly scalable DeFi applications.

  • Binance Smart Chain completes integration with BandChain decentralized oracle network which allows developers to create customized oracles connecting to any external data source or API.
  • There are already 12 price pairs currently available to be read from the BandChain bridge contract on Binance Smart Chain covering cryptoassets that update every 5 minutes, as well as foreign exchange and commodities that update every 60 minutes.
  • The integration with Band Protocol offers an efficient oracle request process, low-cost real-time data, high quality data, end-to-end customizability and decentralization - opening the gateway for reliable DeFi and blockchain applications to be built on Binance Smart Chain.
  • Binance Smart Chain developers are now equipped to build truly scalable products, including DeFi, programmable payments, betting games, VRF applications, prediction markets and more!
  • A step-by-step guide on ‘Building Decentralized Synthetic Asset Platform on Binance Smart Chain Using Band Protocol’s Oracle’ is demonstrated for developers - see the full article below.
  • Combining the scalability of both Binance Smart Chain and Band Protocol’s oracle, both teams are working together in the long-term to drive a new decentralized application ecosystem on Binance Smart Chain focused on innovation and scalable products.

Developers, enterprises, and other Binance Smart Chain ecosystem participants can now utilize Band Protocol’s oracle to connect to any external data source or API using Band Protocol’s solution that is built for flexibility, modularity, and scalability. With the completion of the integration, Band Protocol has been added to the official Binance Chain documentation that provides the following secure price feeds to begin with: BTC/USD, ETH/USD, BNB/USD, BUSD/USD, BAND/USD, XAU/USD, XAG/USD, EUR/USD, CNY/USD, JPY/USD, GBP/USD and KRW/USD.

Band Protocol’s cryptoasset price feeds automatically update once every 5 minutes with the commodity and foreign exchange feeds updating once every hour. Developers can now use Band Protocol’s native price feeds on Binance Smart Chain or build custom decentralized oracles on BandChain, leveraging the short blocktime on Binance Smart Chain and streamlined data request process on BandChain to power all types of decentralized applications including DeFi, prediction, betting and gaming.

Why Band Protocol?

Band Protocol is a cross-chain data oracle platform that aggregates and connects real-world data and APIs to smart contracts on-demand and in real-time. Band Protocol enables smart contract applications such as decentralized finance, prediction markets, and games to be built on-chain without relying on a centralized oracle which has a single point of failure. The project is backed by a strong network of stakeholders including Sequoia Capital, one of the top venture capital firms in the world, and Binance Labs.

Using Band Protocol’s oracle platform, developers are able to create their own custom oracle scripts which have end-to-end flexibility in specifying the data type, data sources, aggregation methods, and security parameters.

Developers will have complete access to Band Protocol’s tools to reliably connect smart contracts to any external data source or API and leverage real-world data within their decentralized applications. This will bring end-to-end flexibility and customizability alongside security for developers to bridge external data sources without onboarding data providers for each feed, high-costs, limited creativity, restricted expansion of product offerings or limitations from various scalability issues common in existing oracle solutions.

Major features of Band Protocol:

  • Optimized For Scalability & Efficiency
    Band Protocol’s oracle mechanism is based on BandChain, an independent high-performant blockchain, which has been built purely for oracle computations such as data sourcing, aggregating, updates and settlement. This prevents applications from consuming delayed or invalid data arising from the limitations of a specific blockchain such as a congestion that previously stalled Ethereum-based oracle feeds for almost 6 hours in March 2020.

  • Low Cost Real-Time Data
    Built on the Cosmos-SDK, BandChain can handle over 1,000 transactions per second and has a very short blocktime of roughly 2 seconds. This means developers can submit an oracle query and receive a real-time update at the cost of the marginal transaction fees on BandChain - that is, users will not be susceptible to inflated and large gas fees as they would on Ethereum or blockchains that are susceptible to congestion. For example, DeFi projects that use Band Protocol would immediately reduce their margin of error from requesting timely price updates as opposed to using the common reference dataset model that only updates once every few hours.

  • High Quality Data With End-to-End Customizability
    Developers can create custom decentralized oracles on BandChain that specify any external data source or API. This protects smart contracts from relying on a single data source and enables multiple high-quality data sources to be aggregated into a single value with a high level of security and resistance to manipulation.

    Band Protocol is able to connect to open, credentialed and premium APIs to pull real-world information from established data aggregators for any data type. Currently, this is integrated on a case-by-base basis and settled manually as the team continues to develop a more scalable solution where fee settlement occurs automatically on-chain.

  • Fully Decentralized Oracle Mechanism
    Band Protocol currently has 59+ validator nodes on the BandChain decentralized oracle network, who are required to stake BAND tokens to participate in the data request process as determined by a randomized stake-weighted algorithm. This ensures that validators are economically aligned to secure the network and perform their jobs without using a centralized whitelist or audit process that is counterintuitive to the notion of decentralization and susceptible to bias.

What Does This Mean For DeFi & Decentralized Applications?

In the past two years, DeFi has grown from a relatively small sector into one with 6 billion dollars in locked value. And while this certainly speaks volume about the sector’s potential, it does come with a cost.

As DeFi and blockchain in general starts to gain greater adoption and usage, Ethereum has started to experience network congestion and high transaction fees. This has led many users to start looking for an alternative in scalability solutions - this is where Binance Smart Chain comes in.

Binance Smart Chain offers a fully Ethereum Virtual Machine (EVM)-compatible platform that many developers are already familiar with, with additional benefits of connecting to Binance Chain’s growing ecosystem of tools and products such as Binance DEX, lending and payment services, and more.

The addition of Band Protocol’s oracle infrastructure allows developers to access frequently updated price data, and customization of a decentralized oracle to their specific needs and is suitable for all DeFi applications, including lending & synthetic assets. This greatly increases the possibilities and flexibilities in what developers can create, leading to an increasingly vibrant ecosystem and benefiting everyone in the process.

Before diving into a step-by-step guide on how to build a synthetic asset platform on Binance Smart Chain using a custom oracle script on BandChain - here’s a list of the ways Band Protocol’s secure oracles can be leveraged on Binance Smart Chain:

  1. DeFi
    DeFi applications on Binance Smart Chain can use Band Protocol to tap into numerous trusted real-world market data sources and also fine-tune the feed parameters from end-to-end including aggregation method, update intervals and validator confirmations.

    The scalability of both Binance Smart Chain and Band Protocol oracles will enable DeFi products such as lending/borrowing, margin trading, derivatives, stablecoin and payment protocols to be created with much better user experience and reliability to operate efficiently in the long run.

  2. Programmable/Conditional Payments
    With the addition of Band Protocol’s flexible oracle scripts, various conditional and programmable use-cases are unlocked on Binance Smart Chain, such as transfer between supply chain parties at particular points of shipment location. Band oracles can be used to verify shipping location and expiry dates to automatically release capital held in smart contracts, reducing the friction of manual payment, paperwork and verifications.



Further applications of conditional payments are international remittance, cross-border payments, payment for services or recurring payments that rely on an accurate exchange rate. Band Protocol can provide a spot market exchange rate for any crypto asset against any fiat currencies based on price information retrieved from various external sources such as data aggregators, centralized and decentralized exchanges.

  1. Automated Portfolio Management
    Leveraging Band Protocol’s ability to connect to any external data source or API, users can bridge off-chain price data, technical analysis indicators such as moving averages, MACD, relative strength index, and real-world events like industry statistics to Binance Smart Chain.

    This data can then be used to automate simple or complex portfolio management and trading strategies directly on Binance DEX while ensuring high resistance to manipulation and reliability through various custom security parameters in the oracle script.

  2. Betting Applications
    Developers can leverage Binance Smart Chain to create reliable and trustworthy betting applications that bring trust and transparency back into the betting industry. These applications rely on a highly secure and reliable oracle to bridge off-chain niche data such as sports and esports results to ensure complete decentralization, visibility and fair settlement.

    With Band Protocol being integrated into Binance Smart Chain, developers can leverage custom data oracle scripts to bridge any external data required to power betting applications without scalability issues and restriction. Ultimately, betting projects will be able to improve security and adaptability to market needs and ramp up speed to market for future product offerings.
  3. Gaming & VRF Applications
    Binance Smart Chain developers can utilize BandChain Verifiable Random Function (VRF) to leverage a verifiably fair random number generator (RNG) in real-time and build products resistant to manipulation. This works by having a selective group of trusted VRF providers who supply random deterministic values based on a specified input or ‘seed’. The selected VRF providers are unable to supply biased outcomes as the cryptographic proof requires the use of the provider’s public key.

    Applications that leverage Band Protocol’s VRF will be able to take advantage of the scalability, customization and low-latency of the BandChain decentralized oracle network. This is critically important for blockchain-based games of lottery applications that use RNG to determine outcomes and rewards and cannot use other VRF solutions that require users to wait an extended amount of time for results.

    BandChain VRF provides a real-time solution with a high level of security guarantee for optimization and better user experience.

  4. Prediction Markets
    With Band Protocol’s oracles in a Binance Smart Chain developer’s toolbox, prediction market creators are able to create an oracle script to bridge any real-world information or APIs on the open internet to the blockchain, including market prices of an asset, election results, weather, flight status and more! This allows markets to be arbitrated in a trustless manner where Band Protocol will be used to verify the market outcome.

    This is a major step in improving the developer and user experience as prediction markets will not be limited to existing reference datasets, required to build a decentralized data feed from scratch or reliant on a centralized market settlement process. The Band Protocol integration with Binance Smart Chain grants developers access to a global pool of economically incentivized validators on BandChain as well as a bridge to the world of off-chain data to ensure fully decentralized market arbitration for any prediction market.

Building Decentralized Synthetic Asset Platform on Binance Smart Chain Using Band Protocol’s Oracle

Note that this tutorial aims to provide a guide to advance users who aim to utilize Band Protocol oracle to the fullest and uses any oracle script available on BandChain. This tutorial is only for the demo purpose not for the production. For a reference price feed usages, you may check out the Guide to Using Band Oracle Data on BSC (Official Doc).

The example below shows how to build a decentralized application on Binance Smart Chain using Band Protocol’s oracle solution.

In the demonstration, a decentralized synthetic asset platform is built, which allows users to seamlessly access traditional stock, commodities, precious metals, ETFs, and more for exposure, store of value or hedge against hyper-inflation.

Application Architecture

A Collateralized Debt Position (CDP) smart contract is built that issues synthetic tokens using the BUSD token as collateral, as well as using a price feed from Band Protocol’s oracle. The diagram below shows how each of the components works together to create a fast, responsive UX suitable for mobile usage.

CDP App Diagram

An important aspect to note is that the price feed from Band Protocol utilizes “batched” transactions that allow the price feed to be attached with the smart contract parameter in the same transaction. This allows Band oracle to operate securely and accurately even in highly congested networks.

All the functions that need price oracle data will take an extra oracle_data parameter. This parameter is the payload from BandChain that packs the oracle request parameters (oracleScriptId) and the request results in one bytes package. Check out Band Protocol’s developer documentation for more details.

Diving Into The Code

The code is hosted here: https://github.com/bandprotocol/band-integration-binance-smart-chain. The contracts themselves consist of 5 functions that will enable trading of the synthetic asset.

  • lockCollateral(amount): transfer BUSD from the user’s wallet to the smart contract as collateral.
  • unlockCollateral(amount, oracle_data): transfer BUSD back to the user. This will be using price data from Band Protocol’s oracle to ensure that there’s enough collateral left after the unlock.
  • borrowDebt(amount, oracle_data): issue synthetic tokens for the user. This requires oracle data to ensure that there’s enough collateral to back the value of the synthetic tokens.
  • returnDebt(amount): burn synthetic tokens for the user. This will free up the amount of collateral the user is required to maintain
  • liquidate(address, oracle_data): anyone can call this function to pay back the borrowed synthetic tokens for the CDP issuer and take the collateral in case that the CDP issuer fails to maintain the 150% collateral ratio.

In addition to the 5 main functions, the smart contract additionally allows the onlyOwner function to set the parameters via the setConfig function. This will allow the contract owner to set the ID of the oracle script and the symbol of the stock to be used when validating the oracle data sent from BandChain.

Full StockCDP Smart Contract Code

https://gist.githubusercontent.com/smiled0g/31871721336dadff6d4cbc9033608fcc/raw/5092d706cb5f380291717d95034900fea2f2502b/StockCDP.sol

Try It Out

A simple web application to demonstrate the functionality of synthetic token issuance on the Binance Smart Chain testnet has been built.

The app can be accessed at https://bsc-synth-stock.bandchain.org/

Login With Testnet Private Key Or Create New Account

CDP Homepage

If you’re creating a new account, you’ll need to get some BNB and BUSD tokens first by copying your newly created address and requesting for the two tokens from https://testnet.binance.org/faucet-smart.

CDP with private key entered

Once you have some BNB to pay for transactions and BUSD to act as the collateral token, you can proceed by clicking the “Login” button.

Once You’e Logged In, You’ll See The Dashboard

main CDP dashboard

In this minimal dashboard, you can see the status of your CDP as well as your BUSD balance.

Locking Up BUSD Collateral To Borrow Macy Tokens

Lock up 12 BUSD as collateral in your CDP.

Lock up 12 BUSD

Afterwards, you’ll see that the amount of collateral will be 12 BUSD.

CDP dashboard with 12 BUSD locked up

At the time of writing, the Macy stock is worth approximately 6.73 USD.

Borrow (mint) 1 Macy token.

Borrow 1 Macy token

If the collateral amount entered is sufficient (i.e. more than 150% of the Macy token you want to borrow in value), the transaction will proceed and you will now own 1 Macy token, which you can spend or use on any decentralized exchanges or other DeFi applications that support it.

synthetic stock balance

Returning Macy Token(s) To Unlock The Collateral

If you want to get your 12 BUSD collateral back, simply initiate “return debt”, which will transfer back the Macy token(s) you’ve borrowed.

return

Click “unlock” to get back the BUSD collateral you put in.

Inspecting BandChain Data Requests

You can also inspect the data requests in real-time from the CosmoScan block explorer: https://guanyu-devnet.cosmoscan.io/requests

devnet explorer requests home page

In each request, you can also inspect further to see how BandChain validators report and aggregate the data for your request.

devnet explorer requests index page

The code repository is available here for you to examine further. Please note, the code and contracts are only intended to serve as a demonstration and have not been audited nor are intended to be used in a production environment.

Wrapping Up

That’s it! You’ve built a decentralized synthetic asset platform on Binance Smart Chain that will allow anyone with a mobile phone to have exposure to traditional financial assets such as stock, commodity, ETFs and more.

Combining the scalability of both Binance Smart Chain and Band Protocol’s oracle, you’ve enabled permissionless trading of money instruments for anyone that owns a mobile phone.

If you have any feedback or questions about Binance Smart Chain or Band Protocol integration, engineers from both teams will be happy to help. You can reach the Binance Smart Chain team on the Binance Chain Developer Telegram Group , and the Band Protocol team on Discord.

Happy Hacking!

About Binance Smart Chain

Binance Smart Chain is a sovereign smart contract blockchain delivering Ethereum Virtual Machine (EVM) compatible programmability. Designed to run in parallel with Binance Chain, Binance Smart Chain retains the former’s fast execution times and low transaction fees while adding Smart Contracts functionality to support compatible dApps.

For more information on Binance Smart Chain, visit:
www.binance.org/#smartChain

About Band Protocol
Band Protocol is a cross-chain data oracle platform that aggregates and connects real-world data and APIs to smart contracts. Blockchains are great at immutable storage and deterministic, verifiable computations — however, they cannot securely access data available outside the blockchain networks. Band Protocol enables smart contract applications such as DeFi, prediction markets, and games to be built on-chain without relying on the single point of failure of a centralized oracle. Band Protocol is backed by a strong network of stakeholders including Sequoia Capital, one of the top venture capital firms in the world, and the leading cryptocurrency exchange, Binance.
Website
| Whitepaper | Telegram | Medium | Twitter | Reddit | Github

Share