Skip to content

Instantly share code, notes, and snippets.

@ice09
Last active February 1, 2021 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ice09/4d0f819c2475ac0292dd31769c1e8671 to your computer and use it in GitHub Desktop.
Save ice09/4d0f819c2475ac0292dd31769c1e8671 to your computer and use it in GitHub Desktop.
xDaiComp

Evaluating xDai Stable Chain for B2B Use Cases

The xDai Stable Chain is an Ethereum sidechain with a native stable coin and a bridge to the Ethereum Mainnet for the native currency xDai, which represents DAI on the Ethereum Mainnet.

A native stable coin is a distinctive feature for financial and other Enterprise use cases which could profit of decentralized aspects of Blockchains, but cannot accept the usage of a highly volatile native crypto currencies.

The xDai Stable Chain is very cheap in transaction fees and very fast, but lacks other important features of the Ethereum Mainnet. This post will try to give enough information to enable the reader to decide if the xDai Stable Chain can be of use for her prototype, PoC, MVP or even a working product.

Intention

Many respected projects recently changed from Ethereum to the xDai or initially started on xDai.
POAP, Circles UBI, Honeyswap and many more projects are currently running on xDai. Their main motivations were the ease of use, the very cheap transaction fees and fast transaction times. Some of the projects started on Ethereum, but had their business models wracked by the extremely high and unpredictable gas fees. All tooling (like Wallets, IDEs, Static Security Analysis, ...) can be reused from Ethereum due to EVM-compatibility.

Main Differences to Ethereum

There are many links with detailed and fair comparisons of Ethereum to xDai (here, here).

TL;DR the main differences are

  • xDai uses a stable coin as a native currency (DAI bridged 1:1 from Ethereum)
  • xDai is very cheap in transaction fees
  • xDai is fast: 5 seconds in average block times
  • xDai is less secure than the Ethereum Mainnet
  • Ethereum roughly has a x100 market cap
  • Ethereum is established, Consensus is proven to work for more than 6 years

Statistics & Chain Properties

Blockscout is the well known block explorer for POA and related chains like xDai. It is similar to etherscan.io for Ethereum and computes different statistics for xDai and the Sokol Testnet: https://blockscout.com/poa/xdai/

Attribute Ethereum Mainnet xDai Stable Chain
Runtime EVM EVM (100% Ethereum compliant)
Blocktime ~15 sec. ~5 sec.
Average Gas Costs >200 gwei (>> $1) 1 gwei (~ $0.000021)
Consensus PoW (soon PoS) POSDAO (delegated Proof of Stake)
Security Level PoW with adapting Hashrate, >100bn market cap dPoS with $10M staked

Should I use xDai for my B2B dApp?

This post should help you to do your own risk assessment, as a rule of thumb, these could be guiding principles:

  • Running your Smart Contracts on xDai makes them very cheap and easy to use for you customers.
  • Security is not the same as with the Ethereum Mainnet.
  • In a financial environment, the low market cap and not established incentives can be a no-go.
  • xDai can be a almost perfect bootstraping environment, up to prototype, PoCs, MVPs and even more.
  • Native stable currency makes xDai distinct from other chains, even Ethereum, and facilitates use cases not possible on native volatile crypto currencies.

Sample Use Case: Hashlocked Payment

This brief example should show how easy Smart Contracts can be implemented with a native stable currency.

The contract is instantiated with a recipient address, a hash lock and a value, which is xDai (wei), so 100 * 10^18 would be equivalent to $100.

The recipient can now call conditionalSend with the correct challenge and will be transferred the stored amount of xDai.

On Ethereum, this could only have been done

  • with ETH as currency (volatile and unpredictable)
  • with DAI as ERC-20 Token

However, with a ERC-20 Token transfer, the logic of the Smart Contract would have been way more complex and expensive. Complexity adds potential bugs, so arguably it would even be more insecure. For sure, it would be more expensive in Gas fees (as the call on xDai costs <$0.001).

This sample should show how easy and straightforward Smart Contract development on xDai can be due to the native stable currency.

contract ConditionalPayment {

    address payable public recipient;
    uint256 public value;
    bytes32 public hashLock;
    
    event Transferred(address _recipient, uint256 _value);

    constructor(address payable _recipient, bytes32 _hashLock) payable public {
        recipient = _recipient;
        value = msg.value;
        hashLock = _hashLock;
    }

    function conditionalSend(string memory challenge) public {
        if (sha256(abi.encodePacked(challenge)) == hashLock) {
            recipient.transfer(value);
            emit Transferred(recipient, value);
        }
    }
}

References for xDai Stable Chain

Possible Use Cases for xDai Stable Chain

Consensus

Fiat Gateways

Current Validators

Incentives

Blockexplorer

Wallets

FAQs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment