Deep dive into Biconomy

The phase of web3.0 and decentralization, specifically in the ethereum and solana ecosystem, has tried to solve lots of challenges which are faced in traditional systems. More and more users are transitioning to these kind of open and permissionless systems. The ecosystem has been evolving and new apps are being built on top of blockchain, which are ready to use for wide adoption but the lot of consumer facing problems are yet unaddressed.

If you want to learn about ethereum, you can always start with these below
Ethereum primer/101, ETHHub, ETH for devs, and glossary.

The problem statement

With such wide variety of protocols and decentralized applications (dapps) being built on a lot of chains (layer1 and layer2), they've become more and more fragmented and cluttered with complicated user experience.

The end user of these protocols and dapps require significant knowledge of how things work under the hood and need to estimate their cost of interacting with them in a better way so that they do not end up overpaying or underpaying the fees (Every interaction, specifically writing to blockchain, requires the user to pay gas fees in the network's native token). Moreover, high gas prices on ethereum has also become a major hurdle for users.

Various layer 2 scaling solutions have tried tacking the problem of high gas fees on ethereum, but it introduces another set of problem such as bridging and managing funds across chains. This makes the usage and liquidity fragmented across chains.

Such drawbacks introduces friction among users and reduces usability of such products. Well, these are some of the major pain points, which biconomy is trying to solve with it's products. This post is meant to be a deep dive into Biconomy Protocol.

TLDR
Biconomy is trying to solve the above mentioned problems with it's multi-chain relayer protocol, which abstracts the technicalities from the user interaction process and makes it as simple and minimalistic as possible for the end users.

The Multi-Chain Relayer protocol

Brief one liner about biconomy

  • Meta transactions
    To understand meta transactions, let us take a step back to understand how a transaction generally works in ethereum. Transactions are signed messages, sent by an account to be executed and recorded on the ethereum (or any EVM compatible) blockchain. The execution of transaction causes the state of ethereum network to change. In order for this to happen, the sender of the transaction has to pay gas fees (it's a unit to measure of computation required for execution of a transaction).

    Well, the important thing is that gas fees needs to be payed in the native currency of the network (ETH for Ethereum), and the sender of the transaction (can be a user account or a smart contract) needs to have sufficient amount of currency for transaction execution.

    So, the users have the following challenges

    1. They need to own native tokens (e.g. ETH for ethereum, MATIC for Polygon, etc.)
    2. They need to estimate gas fees before every transaction (which may vary a lot depending on the current network usage)
    3. High gas prices (specifically on ethereum)

    These challenges introduces lot of friction among users willing to operate any decentralised application. Well, we can overcome these problems because we're aware of the fact that only the account which sends the transaction to the network has to pay fees and here's when meta transactions come to rescue. We can delegate the responsibility starting from estimation of gas fees to paying the fees itself to a middleman (a relayer network).

    • Biconomy Mexa
      To cater the above 3 challenges, mexa is available as a service with the help of the relayer network for the protocol and dapp creators. It manages the whole transaction starting from gas estimation to actually submitting it to the destination blockchain with a 100% success rate.

    There currently are a lot of ERC20 tokens (a token standard for evm based networks, more about ERC20 tokens here and here) and lot of protocols operate on these tokens. The same challenge of owning native tokens is faced by users when they try to interact with these protocols. It's hard to escape paying gas fees otherwise, because you'll need initial source to get native tokens like ETH. If you choose to transfer an ERC20 token to ETH, it still requires ETH to perform transfer :(

    • Biconomy Forward
      Biconomy's forward enables users to pay the fees in ERC20 tokens. User pays the gas equivalent amout to the relayer in ERC20 token, which gets forwarded to the network by the relayer, paying fees in ETH.

    Who pays to biconomy then, you ask? The dapp developer/company, who chooses to integarte and allow their users to use the platform in a gassless fashion. The amount is aggregated (for a particular contract), which needs to be paid at certain intervals.

    Basically, the users interacting with the protocols and dapps using these services, can just sign a single transaction which is handed over to the biconomy's relayer network and further to the destination blockchain.

  • Cross chain
    The above mentioned solutions are available for multiple blockchains and layer 2 solutions, e.g. Polygon, Avalanche, BSC, etc. The protocol will enable frictionless movement of funds across chains by providing cost efficient bridges. Moreover, users can leverage it for cross-chain communication and contract calls (future goal). This all leads to a seamless multi-chain infrastructure for web3.0.

    • Hyphen
      It is a cross-chain bridge to move your funds with very minimal cost. Currently it live and supports 3 networks, Ethereum, Polygon, and Avalanche.
  • Biconomy Protocol Design
    Currently, the protocol of biconomy is semi-centralised in nature, and is moving towards a fully decentralised protocol solution, in coming months. The protocol will consist of following major components

    • Node operators
      • Executors: Responsible for picking up the transactions from relayer network and executing them.
      • Validators: Responsible for listening and verification of transaction request from user along with verification of the work done by executors and reaching a consensus.
    • The biconomy blockchain: The transaction executed by executors and validated by validators are added to a seperate blockchain.
    • Liquidity Providers: Those providing liquidity tokens to the protocol and earn fees and the biconomy token.
    • Delegators: Token holders can delegate their tokens to the node operators instead of running a node themselves. They will earn biconomy tokens in reward.
    • Consumers: The projects/dapps using biconomy's services. Depending on the amount of work requeste i.e. transactions propogated through the relayer network, they will have to pay back the network at regular intervals.
  • Biconomy token
    BICO is the native work and governence token. It plays a key role in decentralizing the network by acting as the network fees, incentivizing all stakeholders to secure and maintain the network, and participating in the network’s governance.

    Moreover, it will be used to pay the network fees for transactions which will be written in the biconomy blockchain. The node operators will earn incentives for contributing to the netwok and keeping the network in consensus. The delegators and liquidity providers will also be rewarded with this token itself.

    As it moves towards complete decentralization, a governance mechanism will be put in place, where users can propose and vote for descisions affecting the protocol using these tokens.

  • Biconomy blockchain
    It will be Proof of Stake (PoS) based blockchain, and users can stake their tokens to become a part of it and contribute. False actors in the network will be slashed and penalized by a slashing mechanism. Further to reduce the trust assumptions on Executors for carrying out the cross-chain transaction or smart-contract calls, Threshold Signature Scheme (TSS) will be used to distribute an authorized key that has the right to execute the transaction on the destination chain.

  • What next for Devs?
    As a protocol/dapp/smart contract developer, you can start using biconomy right away as it's available on majority of popular chains. You can head over to their documentation and have a look at detailed explanations for using meta transactions (mexa and forward).

    A quick explainer for making your dapp support meta transactions.

    • To make your contracts compatible with meta transactions, you'll just need to extend a contract. But wait, there's a catch. You now can't use msg.sender in your contracts functions, atleast in the state change ones as the transaction will be recorded on the destination blockchain by the relayer resulting in the relayer address as it's value and not the user address actually making the call. But, you can use a method (of the extended contract), which will provide you with the value of user (signer of the trasaction), but extracting it from the signature (check this contract out and it's _msgSender() function).
    • A simple contract would look something like this
      ​​​​​​​​pragma solidity ^0.6.2;
      
      ​​​​​​​​import "https://github.com/opengsn/forwarder/blob/master/contracts/BaseRelayRecipient.sol";
      
      ​​​​​​​​contract Relayer is BaseRelayRecipient {
      
      ​​​​​​​​    mapping(address => string) private names;
      ​​​​
      ​​​​​​​​    constructor() public {
      ​​​​​​​​        // Polygon Mumbai Testnet forwarder address
      ​​​​​​​​        trustedForwarder = address(0x9399BB24DBB5C4b782C70c2969F58716Ebbd6a3b);
      ​​​​​​​​    }
      
      ​​​​​​​​    function setName(string memory _name) public {
      ​​​​​​​​        // using _msgSender() instead of msg.sender
      ​​​​​​​​        names[_msgSender()] = _name;
      ​​​​​​​​    }
      
      ​​​​​​​​    function getName() public view returns (string memory) {
      ​​​​​​​​        return names[msg.sender];
      ​​​​​​​​    }
      
      ​​​​​​​​    function versionRecipient() external view override returns (string memory) {
      ​​        return "1";
      ​​​​​    }
      ​​​​​​​​}
      
    • On contract deployment, you need to register your contract and functions which will be using meta transactions on the biconomy dashboard.
    • Once this is in place, you can use their JS SDK (@biconomy/mexa) in your app/backend. A detailed usage guide along with code snippets for using it with web3/ethers are provided in the documentation.

    Hence, biconomy abstracts out a lot of hassle through their dashboard and JS SDK for the consumers.

  • A minor caveat
    While making a contract call, generally on any EVM compatible blockchain, you can checkout the contract call being made using the wallet (preferably metamask). The image given below shows a contract call setName() in a contract which is not yet supporting meta transactions.

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More β†’

    You can see in data, which function is being called.

    In case of meta transaction, you'll need to sign a message which first needs to be sent to the relayer network and then the relayer network is responsible for submitting it on blockchain. Think of it as a wrapper signature on top of original transaction signature.

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More β†’

    This becomes risky, because the signing of the transaction remains is dark. A malicious dapp can ask us to sign something, and actually can make us sign something else.

  • Final thoughts
    Now that we've seen how it works, it can be surely considered as one of the promising projects of the web3 ecosystem and will play a significant role in mass adoption of blockchain based solutions. Moreover, following a principle of progressive decentralization helps in maintaining the trade off for development and releases against bulding trust and security with time.

    Finally, big ups to Superteam for onboarding great indian talent and helping in collaborative growth of the community. Check more about superteam here. Thank you for reading. Onwards and Upwards

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More β†’

  • References