0.2.2 • Published 4 months ago

@wandevs/message v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Wanchain Message Bridge (WMB)

Wanchain Message Bridge (WMB) is a decentralized messaging protocol that allows messages to be transmitted between different blockchain networks, including Wanchain and other networks.

The protocol is implemented through the Wanchain Message Bridge smart contracts, which enable the transmission of messages between different chains.

The contract code mainly consists of two parts: one part is WmbGateway, and the other part is WmbApp and WmbRetryableApp.

WMB Gateway

The WMB Gateway is a smart contract that acts as an intermediary between the Wanchain Message Bridge and the external blockchain networks. It provides a secure and efficient mechanism for transferring messages between the different networks.

Deployed SC address

Testnet

NetworkContract Address
Wanchain Testnet0xEB14407Edc497a73934dE08D5c3079BB1F5f145D
Ethereum Goerli Testnet0x9454C2F15F308098163623D5E7deCe366793efD3
Avalanche Fuji Testnet0x8Ee72C8194ec8A527B1D4981742727437091C913
XDC testnet0x8c1b9daD87BFC48DF48b15baA19d0FB163030169
Arbitrum Goerli Testnet0x294B79d3D13DAb36C51C8E4Cf3c2Cd3948F0bA4C
Optimism Goerli Testnet0x9B9492466F70e0dA0f4ef0aC27a53550B0769232
Polygon Mumbai Testnet0x61F4aBa60A158E180521264a793fCb2901fCe998

Mainnet

NetworkAddressBip44 chainId
Polygon0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332147484614
BSC0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332147484362
Wanchain0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332153201998
Avalanche0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332147492648
Optimism0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332147484262
Arbitrum0x7280E3b8c686c68207aCb1A4D656b2FC8079c0331073741826
Energi0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332147493445
Ethereum0x7280E3b8c686c68207aCb1A4D656b2FC8079c0332147483708

WMB App

WMB App is a smart contract that can be inherited by third-party DApps to interact with the WMB Gateway. It provides a customizable interface for interacting with the WMB Gateway and handling incoming messages.

WMB Retryable App

WMB Retryable App is a smart contract that can be inherited by third-party DApps to interact with the WMB Gateway. It provides a customizable interface for interacting with the WMB Gateway and handling incoming messages. It also provides a retry mechanism for handling failed messages.

Compile & Test

// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
import "@wandevs/message/contracts/app/WmbApp.sol";

contract MyContract is WmbApp {
    
    constructor(address admin, address _wmbGateway) WmbApp() {
        initialize(admin, _wmbGateway);
        // 你的初始化代码
    }

    function _wmbReceive(
        bytes calldata data,
        bytes32 messageId,
        uint256 fromChainId,
        address fromSC
    ) internal override {
		// do something you want...
    }

    function sendMessage(
        uint256 toChainId, address toAddress, 
        bytes memory msgData, uint256 gasLimit) public payable {
        uint256 fee = estimateFee(toChainId, gasLimit);
        require(msg.value >= fee, "Insufficient fee");
        _dispatchMessage(toChainId, toAddress, msgData, msg.value);
    }

    function sendMessageBatch(
        uint256 toChainId, Message[] memory messages, uint256 gasLimit) 
        public payable {
        uint256 fee = estimateFee(toChainId, gasLimit);
        require(msg.value >= fee, "Insufficient fee");
        _dispatchMessageBatch(toChainId, messages, msg.value);
    }
}

Sandbox Environment

Check sandbox.md for more details.

0.2.2

4 months ago

0.2.1

7 months ago

0.1.2

7 months ago

0.2.0

7 months ago

0.1.4

7 months ago

0.1.3

7 months ago

0.1.1

11 months ago

0.1.0

11 months ago