WebAssembly Technology in the Bifrost Network

Bifrost is designed to provide liquidity for staked assets (e.g. PoS Consensus Staking mechanism, staked assets under the Relaychain slot bidding asset locking mechanism) and to be fully decentralised. Bifrost is therefore presented in the form of a DeFi protocol and blockchain system.

Bifrost is being developed using the Substrate framework and at this stage. Bifrost will operate as a parachain within the Polkadot system. This will allow it to share the consensus security of the Polkadot relay chain, and to interact effectively with the Polkadot relay chain, other parachains or parathreads. As the DeFi base protocol for the Polkadot ecosystem, Bifrost strives to be the infrastructure for providing liquidity to staked assets.

Image from WebAssembly: How and why

WebAssembly, or WASM for short, is a stacked virtual machine technology. Initially used primarily in the Web domain, WASM is the fourth widely adopted Web programming language after HTML, CSS and JavaScript, and because WASM code is cross-platform, portable and runs at near hardware instruction speed, WASM is not limited to running only in Web browsers. Its host runtime environment can be an operating system, a blockchain system, or any application that wishes to provide programmable features to its users. Due to the excellent design and performance of WASM, most of the current well-known public chain projects tend to adopt WASM technology at the Runtime and Smart Contract level.

WASM for Runtime

Substrate is the common blockchain development framework within the Polkadot ecosystem. To enable forkless upgrades of blockchain systems, the Substrate framework supports blockchain system Runtime source code built on top of it, compiled into target code for the WASM platform and ready to run in the WASM virtual machine. When an upgrade is needed, the upgraded target code can be sent to the chain, accessed by each node in the blockchain network, and then approved by community voting or other governance rules to automatically complete the system upgrade, effectively avoiding community fragmentation and system forking.

WASM for Smart Contract

Bifrost currently offers vToken, a derivative for Staking locked-in assets, and vsToken, a derivative for bidding on locked-in assets in the PoC parachain slot. vToken and vsToken can be staked, received and traded in multiple scenarios such as DeFi, DApp, DEX and CEX. Through derivatives, Bifrost opens up a channel for transferring staked interests such as Staking and PLO, helping users to hedge the risk of staked assets. A wide range of derivatives are available, including vDOT, vKSM, vETH, vsDOT, vsKSM and vsBond assets. vsBond in turn contains a large number of Token varieties. These derivatives will inevitably lead to richer and more flexible application scenarios, so the Bifrost platform needs to provide efficient smart contract functionality.

Image from WebAssembly: How and why

A typical example of a smart contract virtual machine is the EVM in the Ethernet system. As an early smart contract technology, the overall design of the EVM is not conducive to fast running contract code. EVM smart contracts have shown a number of security vulnerabilities. Running smart contracts on a WASM virtual machine is a better option than EVM and is in line with technology trends. Many blockchain projects, including the Ether 2.0 project, are currently planning to use WASM Virtual Machines as the execution environment for smart contracts, and Bifrost is no exception.

Implementation differences between Runtime and Smart Contracts

Although both Runtime and Contract can run in a WASM virtual machine, the choice of WASM virtual machine differs depending on the role, function and size of each. From a system design perspective, the Runtime runs in the OS system environment, while the Contract runs in the Runtime environment or is executed by a separate runtime environment initiated by the Runtime. Wasmtime implements JIT technology for faster operation, and Wasmi interprets and executes the WASM instructions corresponding to the contract code to ensure consistency in the execution of contracts across the network.

Bifrost’s smart contract billing strategy

There are several existing smart contract billing strategies:

  • Billing based on the actual amount of instruction execution and storage space consumed.

  • Share computing, communication and storage resources of the entire system in proportion to the amount of money held.

  • Billing based on the actual share of resources leased and the length of the lease.

The payer of a smart contract can be either the user or the DAPP project owner. If the contract project pays for the operation of the contract, special consideration will need to be given to how to deal with the large number of spam transactions that launch malicious attacks (although the transactions themselves pay a base fee, the contract project may pay a higher fee). The exact percentage can be set by the DAPP/contract project. As the Bifrost system is designed with a Flexible-Fee mechanism, contract fees may be paid not in BNCs, but in the form of asset Tokens issued by the project owner, or any other valuable asset Token. To encourage DAPP developers and project owners, the Bifrost platform is also considering subsidising or rebating a portion of the BNCs from the treasury or miner fees.

The state of the WASM contracting technology ecosystem

The EVM ecosystem has developed over the years and has a rich community of contract developers and supporting tools, so that EVM contract developers can have a richer set of examples to draw from and beginners can get started quickly. The Patract technical team is currently helping to build a variety of contract development and debugging tool chains for the Polkadot ecosystem, and the main development tool suites available from Patract are.

  • Redspot, similar to Truffle, is a tool for project-based contract development.

  • Europa, similar to Ganache, which provides a simulation node for contract runtime environments.

  • Metis, similar to OpenZepplin Contracts, which sets up template contracts for the developer ecosystem.

  • Ask!, an AssemblyScript-based contract programming language, is a variant of TypeScript and may be more popular with developers.

Bifrost has partnered with Patract to enable developers to deploy Dapps and smart contracts on the Bifrost platform without additional learning, using the ask! or ink! contract programming language, supported by Patract’s many tools and software.

What is Bifrost?

Bifrost is the Polkadot Ecological DeFi basic protocol. It is committed to becoming an infrastructure for staked assets to provide liquidity. Bifrost launched derivatives vsToken for Staking and Polkadot Parachain Slot (Crowdloan). It has obtained $2.15M in fund-raising from NGC, SNZ, DFG, CMS and other institutions and Web3 Foundation Grant. It is also a member of Substrate Builders Program and Web3 Bootcamp.

vToken can optimize transactions in multiple scenarios such as DeFi, DApp, DEX, CEX, and realize the transfer channel of stake rights such as staking and Crowdloan through vsToken, realize the risk hedging of stake assets, and expand scenarios such as vToken as collateral for lending, its staking reward part of the interest can be offset to achieve low-interest loans.

Learn more about Bifrost

Website | GitHub | Telegram | Medium | Twitter | Discord | SubSocial

Bifrost is the Polkadot Ecological DeFi basic protocol. It is committed to becoming an infrastructure for pledged assets to provide liquidity. It has launched a derivative vToken for Staking and Polkadot Parachain... Learn More

0 comments