Skip to content

altaga/X-Chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X-Chat License: MIT


IMPORTANT!

Application:

X-Chat Wallet/Dapp APK: LINK

Services and Chains:

Here is our main demo video:

Demo

Introduction and Problem:

Hello and welcome to X-Chat (Cross Chat), the revolutionary Dapp that allows you to chat and send assets across EVM and ZK compatible chains.

While we were looking for a problem to hack we saw that in almost every single one of the EVMs and rollups in the Ethereum ecosystem there was an inherent need to create a UI and protocol for address to address messaging within each one of these chains

In the world of blockchain technology, interoperability between different chains has always been a challenge. But with X-Chat, we have created a solution that enables users to seamlessly communicate and transact across various chains. Whether you're an investor looking to move assets between different chains or a developer building a dapp that requires cross-chain communication, X-Chat has got you covered.

Solution:

With our user-friendly interface and cutting-edge technology, X-Chat offers a secure and efficient way to chat and transact across chains. Our platform is built on the latest blockchain infrastructure, ensuring fast and reliable transactions at all times.

So, whether you're a seasoned blockchain enthusiast or new to the world of decentralized applications, X-Chat is the perfect platform for you to connect with others and explore the endless possibilities of the blockchain ecosystem.

System's Architecture:

All messages, assets and files that are sent from one chain to another are sent through the xcall function in the contract deployed in the origin chain, which is passed to the Connext network to reach the xReciever in the contract deployed in the destination chain. The messages, assets and files that go within the same chain call the own contract of that chain, in this case the chains that are not compatible with connext have their own contract without xcall or xReciever.

X-Chat React Native DApp:

X-Chat is a very complete Dapp, which provides us with all the wallet and chat services. Not to mention its ability to perform crosschain operations.

Within the crosschain capabilities, the most important in our opinion is the fact of being able to send chat messages from one chain to another and in turn being able to transfer ERC20 tokens without any difficulty thanks to our simple UI and Connext services.

Finally, thinking about the performance of the app, a simple design was sought that could easily run on cell phones from high-end to low-intermediate range.

Connext:

All transactions that require communication from one chain to another use the Connext SDK this implementation is in the contract Xchat-crosschain.

Before sending the message, we have to obtain a relayerFee which we have to send as a value within our transaction for the transfer to be successful, the script to obtain the relayer fee is as follows.

const sdkConfig = {
        network: "mainnet",
        chains: {
            6648936: {
                providers: ["https://api.securerpc.com/v1"],
            },
            1869640809: {
                providers: ["https://mainnet.optimism.io"],
            },
            1886350457: {
                providers: ["https://arbitrum-one.public.blastapi.io"],
            },
            1634886255: {
                providers: ["https://arbitrum-one.public.blastapi.io"],
            },
            6450786: {
                providers: ["https://bsc-dataseed1.defibit.io"],
            },
            6778479: {
                providers: ["https://rpc.gnosis.gateway.fm"],
            }
        },
    };
    const { sdkBase } = await create(sdkConfig);
    const originDomain = chainIn.toString();
    const destinationDomain = chainOut.toString();
    // Estimate the relayer fee
    try{
        const relayerFee = await sdkBase.estimateRelayerFee({
            originDomain,
            destinationDomain
        })
        return (relayerFee.toString())
    }
    catch{
        return("0")
    }

The flow of sending the message is to call the sendMessageX function from the contract displayed in the source chain.

function sendMessageX(
    address target,
    uint32 destinationDomain,
    address _to,
    string memory _message,
    uint256 relayerFee,
    uint256 _amount,
    address _token
) external payable {
    bytes memory callData = abi.encode(
        msg.sender,
        _to,
        _message,
        _amount,
        _token
    );
    connext.xcall{value: relayerFee}(
        destinationDomain, // _destination: Domain ID of the destination chain
        target, // _to: address of the target contract
        address(0), // _asset: address of the token contract
        msg.sender, // _delegate: address that can revert or forceLocal on destination
        0, // _amount: amount of tokens to transfer
        0, // _slippage: max slippage the user will accept in BPS (e.g. 300 = 3%)
        callData // _callData: the encoded calldata to send
    );
}

Later, when calling xcall, it will send this information from the source chain to the destination chain, which has an xReciever implemented in its own contract, which will process the call and, in our case, will add the message to the history.

function xReceive(
    bytes32 _transferId,
    uint256 _amount,
    address _asset,
    address _originSender,
    uint32 _origin,
    bytes memory _callData
) external returns (bytes memory) {
    (   
    address _from,
    address _to,
    string memory _message,
    uint256 amount,
    address token
    ) = abi.decode(_callData, (address, address, string, uint256, address));
    addMessageX(_from, _to, _message, _origin, amount, token);
    return "ok";
}

Finally, the communication can be summarized in the following schematic.

All the transactions that we show in the demos can be reviewed in the Connext Explorer.

https://connextscan.io/address/0x2A9EF6632842f2FB3da32Ac0A558B3b7062C0F13

Gnosis:

In our development we use the Gnosis MAINNET, since it allows our application to have a secure layer and with a stable native token, in this case xDai, for our application it is very beneficial to be able to keep fees low when sending messages or USDC tokens from Gnosis to any of the other chains in Connext or to the same chain.

In the following screens of our app, we can see the cost per message within the same chain is less than 1 cent and 6 cents in a crosschain transaction with polygon.

Scroll:

Scroll has a very big benefit for our X-Chat application, since using it we were able to obtain presumable speeds of 3 seconds between messages, in addition to being able to quickly send USDC over the same network quickly.

As we mentioned the costs for sending messages by Scroll are quite low, here is a screen shot showing some costs per transaction which are not usually greater than 0.0008 dollars.

Optimism:

For the Optimism network we wanted to attack a problem directly that they are looking for, which is creating a UI and protocol for address to address messaging and the contract is deployed on MAINNET.

Something very remarkable about Optimism was the costs per transaction that it offered us to send messages on the same chain and crosschain, not exceeding 0.0008 usd and 0.0023 usd respectively.

Mantle:

The Mantle network offered us an architecture with low fees and high security, despite still being Testnet and having low gas fees at the time of uploading this project, it was a network that offered us good transaction speed and full compatibility to deploy our contract in it, working perfectly, managing to send WETH tokens, messages and files.

The network offered us good speed when sending messages and a very low cost in transactions.

Taiko:

For the use of Taiko, special attention was paid to the UI/UX of the project, since it is something that many applications, when they are very focused on developers, tend to lack, so we tried to make a simple interface to be able to send messages over the network. of Taiko and in turn one of its ERC20 Tokens BLL.

Here are some screenshots of our UI and how we send messages, files and show the balance of our wallet.

Polygon

Being one of the most popular Chains and with a huge flow of transactions per minute, it is normal to think that it can be used to interact with other chains by sending stablecoins such as USDC or just having a pleasant conversation with friends at a very low cost. per transaction.

In this network it was very noticeable that the cost per transaction and even crosschain transactions were very fast and very low cost, this could be affected if the network was very congested, but being a layer 2 with good speed this is a rare occurrence .

Current state and what's next:

With our user-friendly interface and cutting-edge technology, X-Chat offers a secure and efficient way to chat and transact across chains. Our platform is built on the latest blockchain infrastructure, ensuring fast and reliable transactions at all times. So, whether you're a seasoned blockchain enthusiast or new to the world of decentralized applications, X-Chat is the perfect platform for you to connect with others and explore the endless possibilities of the blockchain ecosystem. Thank you for reading!

Team:

3 Engineers with experience developing Blockchain, IoT, AI and hardware solutions. We have been working together now for 5 years since University.

References:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published