Wrapped Hive v2.0 - Open sourcing - Part 1 - Solidity

in #whive3 months ago

Wrapped Hive

Open Source
Part 1 - Solidity

original image source

It's been some time since my last Wrapped Hive update, and I'm a little behind schedule (~1 week), but I have some exciting news to share.

The first part of our code is now open source and ready for review by fellow devs. This includes both wHive token contract and multi-signature smart contract. Both of them are written in solidity.


Code: https://github.com/fbslo/multisignature-contract

While Hive is pretty generous with 40 account auths possible, Ethereum can be more expensive, while in theory there is no limit (except gas per block), it can get quite expensive. Here is some benchmarking I did (this is cost for one hive-to-whive converison):

# of ValidatorsGas costCost in ETH @ 100 gweiCost in USD (ETH @ 1,966)
10400,223 gas0.040022378,69
20692,550 gas0.069255136,16
301,015,056 gas0.1015056199,56

Transaction fee also depends on network congestion, if the gas price is 20 gwei, the fee will be 80% lower than if it's 100 gwei.

While $200 is very high for someone who is wrapping 100 HIVE, it's probably acceptable for someone who is wrapping 1,000,000 HIVE.

I expect wHIVE network to be the "backbone", while smaller centralized bridges can be used to wrap smaller amounts (similar to Hive-engine and LeoDex) with lower fees.

Token Contract

Code: https://github.com/fbslo/token-contract

It's a standard mintable & burnable OpenZeppeling ERC20 contract, but it's extended with 2 additional functions and 1 event convert(uint256 amount, string username):

convertToken (contract.sol#L955)

function convertToken(uint256 amount, string memory username) public {
    _burn(_msgSender(), amount);
    emit convert(amount, username);

convertTokenFrom (contract.sol#L967)

function convertTokenFrom(
    address account,
    uint256 amount,
    string memory username
) public {
    _burnFrom(account, amount);
    emit convert(amount, username);

These functions add an option to include hive username to burn transaction, so validator nodes can transfer unwrapped HIVE.


If you like my work, please support me by voting for my Hive Witness!
Witness announcement


bravo, fbslo! good article

Congratulations @fbslo! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You published more than 350 posts.
Your next target is to reach 400 posts.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Hive Power Up Day - March 1st 2021 - Hive Power Delegation
Hive Tour Update - Communities

Good article, thanks. But gas fees are too much. :(

Amazing. Waiting for reviews to pop up, once everything is fine I'll add 10k hive in the pool.

This is excellent. I would love to see HIVE available on DeFi platforms. It would help bridge the gap between decentralized finance and decentralized social media.
Wrapped Hive would be perfect for incentivized liquidity pools on Sushiswap (Onsen), PancakeSwap, multichain, etc.
Please keep up the development! This would be great for the community and bring in a lot of new Crypto-savy users!