Cover photo

Ether Chat | ​​ The next-generation on-chain chat system

Overview

This is a system that communicates with each other in on-chain chat rooms. It has no centralized servers, no border restrictions, and no regional restrictions. Everyone can read and write in the decentralized chat room

Chat

You can freely read and write resources in any chat room without any restrictions

When you use it, you just need to connect the blockchain nodes and you can have the power to do everything you want

Even human beings reach the interstellar age

post image

The data storage layer is all decentralized

It deploys a smart contract to store data, this is its code

pragma solidity ^0.8.0;

contract EtherChat {
    uint256 public id;

    event Write(
        address indexed _token,
        address indexed _owner,
        string _content,
        uint256 _id
    );

    function write(address _address, string memory _content) public {
        _write(_address, _content);
    }

    function _write(address _address, string memory _content) internal {
        emit Write(_address, msg.sender, _content, id++);
    }
}

As you can see, its code goal is to use an event to store data and do nothing else

This will control the value of the gas, which will fluctuate from 21000 to infinity, the size of the gas fee will depend on the length of bytes in the blockchain that the string you store will occupy

Name and image support

When the contract address of your chat room is in ERC20 or ERC721 format, it will automatically parse the name attribute in the contract as the name of the chat room

More special than ERC20, the contract of ERC721 will automatically resolve the TokeURI whose tokenId is 1 as the avatar of the chat room

post image

Token economy

Each chat room can be set up as an economy, and everyone who loves this group can participate in createLP, and then jointly construct trading pairs and tokens

You can now click the yellow createLP button to fill the reservoir with ETH

post image

When the reservoir is full, the createLP button will turn green, at this time you can click it and get a token reward

post image

It will create 10000000000 tokens

Tokens will be

15% to the liquidity pool 7% to whoever executes the yellow button createLP 3% as a handling fee to the platform 75% distributed to investors

ETH in the chatroom will be

97% will be given to the liquidity pool 3% will be given to the platform as a handling fee


        uint256 fee = (chatroomStatus[_chatroom].totalFund * 3) / 100;

        token.transfer(pair, (totalSupply * 15) / 100);
        token.transfer(msg.sender, (totalSupply * 7) / 100);
        token.transfer(owner(), (totalSupply * 3) / 100);

        payable(owner()).transfer(fee);
        uint256 pairAmount = chatroomStatus[_chatroom].totalFund - fee;
        weth.deposit{value: pairAmount}();
        weth.transfer(pair, pairAmount);
        IUniswapV2Pair(pair).mint(address(this));

Here is an example transaction https://rinkeby.etherscan.io/tx/0xba080b8a3cbdd6dbe56173f8eb8bad3b4db650cc3823a68daf8ad867e456ad5b

post image

Now that the LP is successfully created, you can see the price. If you participate in the investment, you can see the yellow Claim button, click it and you will get the tokens returned to you

post image

For example Mike invested 1ETH Lucy invested 2ETH The total amount of tokens is 10000000000 The tokens distributed is 7500000000 Mike will get 7500000000**1/3 token Lucy will get 75000000002/3 token

Below is an example and code https://rinkeby.etherscan.io/tx/0x6337763d86b086d037229142317ea4e7e5e066705f1ef9f69684319b4884ac3a


    function getClaimAmount(address _chatroom) public view returns (uint256) {
        uint256 amount;
        for (uint256 i = 0; i < chatroomFund[_chatroom].length; i++) {
            if (chatroomFund[_chatroom][i].owner == msg.sender) {
                amount += chatroomFund[_chatroom][i].amount;
            }
        }
        uint256 claimAmount = (((chatroomStatus[_chatroom].token.totalSupply() *
            amount) / chatroomStatus[_chatroom].totalFund) * 75) / 100;
        uint256 contractLeftAmount = chatroomStatus[_chatroom].token.balanceOf(
            address(this)
        );
        if (contractLeftAmount < claimAmount) {
            claimAmount = contractLeftAmount;
        }
        return claimAmount;
    }

You can click the green transaction button, it will jump to uniswap, you can trade and exchange

post image

post image

Finally

Decentralized communication will be the only direction of this product. There is very little done here. This is just the beginning. If you like it, you can click on the website to use it.

Website : https://etherchat.xyz

Of course, this website is just a temporary storage point for us in the web2 world, and we can meet again in the era of interstellar communication