Why and How to Port From Ethereum to VeChain.

Totient
Totient
May 17 · 5 min read

Scalability on Ethereum is potentially years away, but dApp adoption is just around the corner. VeChain is a fully featured smart contract platform based on the EVM and is a perfect match for decentralized applications seeking usage today.

Why VeChain?

VeChain is a smart contract platform with an emphasis on adoption and user-experience. It uses a variant of DPoS as its consensus mechanism to enable high throughput and easy upgradability. Instead of reinventing the wheel, VeChain utilizes the EVM and supports the web3 standard.

Most importantly, VeChain is the only smart contract platform with native fee delegation and other meta transaction features that solve major hurdles for making usable applications.

The largest barrier in user onboarding is the acquisition of cryptocurrency. Most decentralized applications require the user to hold the gas token at the very least in order to use the network. For non-crypto savvy users, acquiring these tokens is a daunting and unnecessary task.

99% of first time users do not make it through the initial onboarding flow of a dApp on Ethereum.

With fee delegation, dApps and wallets can pay for transaction fees on behalf of the user, skipping the most significant filter in the onboarding funnel.

While fee delegation is technically possible on Ethereum, it is far from being a clean solution and is difficult to properly implement for developers. On Ethereum, fee delegation is accomplished with gas relayers and comes at the cost of decentralization.

In the gas relayer model, users must trust a single relayer to promptly transmit transactions on their behalf, and the relayer must trust that the user did not send the transaction to any other relayers. This creates a central point of failure and opens up attack vectors through implementation edge cases.

The gas relayer model is an inconvenient method to implement fee delegation for both users and developers.

VeChain implements fee delegation natively with VIP191, which uses a designated gas payer model. Instead of depending on a single relayer, an unsigned transaction can be broadcasted to a pool of gas delegators. The delegators may then add their signature to the transaction to designate that they’d like to be the gas payer. The user, or more likely the user’s wallet, may then choose from any of the responding gas delegators, before signing and sending the finalized transaction.

In the designated gas payer model, the user maintains complete control over if and when the transaction is signed and sent, maintaining censorship resistance.

In addition to fee delegation, VeChain has support for other meta-transaction features such as atomic transactions and transaction dependency.

Atomic Transactions
As part of the transaction protocol, VeChain allows for multiple function calls (called clauses) to be batched into a single transaction. This allows developers to compose this-then-that atomic functionality without the need for wrapper contracts.

Atomic transactions can drastically reduce the number of steps to onboard users by bundling all necessary setup transactions into one.

Transaction Dependency
VeChain also allows transactions to depend on one another. This is similar to the usage of nonces in Ethereum but takes it even further by allowing transactions to depend on the completion of another specific transaction.

Using Transaction dependency, dApps can create a background DAG of pending transactions, instead of blocking the user with each one.

One of the major setbacks for adoption on Ethereum is the inability for the network to support a sufficient level of throughput for even a single dApp. When CryptoKitties rose to fame in 2017 it was peaking at ~15,000 daily active users and brought the blockchain grinding to a halt.

Scalability on Ethereum is potentially years away, but dApp adoption is just around the corner.

VeChain is tackling this by instead using a variant on the DPoS consensus algorithm to provide a platform that is reasonably scalable at launch, with the tools required to easily upgrade the protocol as advancements are made with blockchain scaling solutions.


Developing on VeChain

Developing on Vechain is very similar to developing on Ethereum. VeChain uses the EVM and is web3 compatible. Developers can still use their favorite environments like Truffle, and contracts can be written in Solidity or Vyper.

With its similarities, there are a few key differences that will be covered in this guide.

  1. Setting up a development environment to work with VeChain’s nodes.
  2. Using VeChain’s smart contract extensions.
  3. Extending web3 to support VeChain.

Note: Vechain has a native version of web3 is called Connex. Since this guide is focused on porting from Ethereum, we will specifically discuss building web3 dApps with VeChain.

This guide assumes the usage of truffle, however, this setup should work with any Ethereum tooling.

Diagram of development stack for web3 dApps on Vechain

Web3-gear
VeChain’s nodes have a different interface than Ethereum’s. In order to get Ethereum tooling working with VeChain, there is a tool called web3-gear. This is a python proxy server that can run locally and provides an Ethereum-looking interface to the Ethereum tools while converting and forwarding requests to a local VeChain node. Once running, the Ethereum developer environment should work as expected with a local Vechain node.

Further documentation on setting up a local VeChain environment.

Contracts on VeChain are largely the same as Ethereum with the addition of contract extensions called built-ins. These helper functions facilitate many of the Vechain-specific functionality such as on-chain governance and contract-based fee delegation support.

Though not required for purely a migration, developers may find this extra functionality to benefit their already existing applications.

Further documentation on using built-ins

Like with Ethereum, the web layer of an application can be built using the web3 standard. Comet, similar to Metamask but for VeChain, supports web3 so that dApps may keep their standard interfaces.

Thorify is a js library that utilizes web3’s extension functionality to make it compatible with Vechain’s node interface. Most web3 functions work as one would expect.

Signature Standards
The personal sign standard on VeChain is slightly different than on Ethereum, defined by VIP190. This will be one of the only areas of the application that needs to be modified when porting.

To be further compatible with web3 standards, Comet also supports EIP712 directly (which we recommend using over VIP190), in which case it is compatible with the Ethereum implementation and no updates are necessary.


Next Steps

For full developer documentation, visit https://doc.vechainworld.io/docs.

If you have any questions about building on VeChain, join one of the very helpful developer communities below.

Thanks to Valkyrie Protocol.

Totient

Written by

Totient

Totient is an activist crypto hedge fund and blockchain venture studio.