• Solutions
  • Developers
  • Blockchains
  • Blog
Wormholescan
Subscribe

Subscribe for updates

Subscribe to the Wormhole newsletter for exclusive updates.

Use Multichain Apps

Products

MessagingQueriesConnectNTTGateway

2024 Ⓒ Wormhole. All Rights Reserved.

The best cross-chain development stack   

Wormhole provides you with the tools and primitives for cross-chain use cases ranging from simple messaging to cross-chain apps.

Get startedGet in touch

Common use cases

Assets

Cross-chain tokens and NFTs are path-independent and fungible.

Apps

Developers from multiple ecosystems can build apps that access more users and liquidity from other chains.

Data

Break data silos to offer high performance, low-cost access to data from other chains and applications.

Explore

One integration for a heterogeneous set of chains

Leading protocols are building on Wormhole.

Wormhole Core

Explore integration scenarios.

Token Bridge

Leverage cross-chain fungible assets, powered by Wormhole.

Cross-chain messages as easily as calling a contract

Explore our messaging docs:

1//SPDX-License-Identifier: MIT
2pragma solidity ^0.8.0;
3
4import "./Wormhole/IWormhole.sol";
5
6contract Messenger {
7    address private wormhole_core_bridge_address = address(0xC89Ce4735882C9F0f0FE26686c53074E09B0D550);
8    IWormhole core_bridge = IWormhole(wormhole_core_bridge_address);
9
10    function sendMsg(bytes memory str) public returns (uint64 sequence) {
11    //Publish Msg takes uint32 nonce, bytes payload, uint8 consistency level
12    sequence = core_bridge.publishMessage(nonce, str, 1);
13    nonce = nonce+1;
14  }
15}

1struct WormholeMsg {
2  uint8 version;
3  uint32 timestamp;
4  uint32 nonce;
5  uint16 emitterChainId;
6  bytes32 emitterAddress;
7  uint64 sequence;
8  uint8 consistencyLevel;
9  bytes payload;
10
11  uint32 guardianSetIndex;
12  Signature[] signatures;
13
14  bytes32 hash;
15}

1function receiveWormholeMsg(bytes memory encodedMsg) public {
2  (IWormhole.VM memory vm, bool valid, string memory reason) = core_bridge.parseAndVerifyVM(encodedMsg);
3  
4  //1. Check Wormhole Guardian Signatures
5  require(valid, reason);
6
7  //2. Check if the Emitter Chain contract is registered
8  require(_applicationContracts[vm.emitterChainId] == vm.emitterAddress, "Invalid Emitter Address!");
9
10  //3. Check that the message hasn't already been processed
11  require(!_completedMessages[vm.hash], "Message already processed");
12  _completedMessages[vm.hash] = true;
13
14  //Do the thing
15  mymsg = string(vm.payload);
16}

Start building cross-chain today

Get in touch with the Wormhole team who can provide you with the resources you need to start building cross-chain.

Get in touch

Subscribe for updates

Subscribe to the Wormhole newsletter for exclusive updates.

Products

MessagingConnectGateway

About

Terms of UsePrivacy Policy

2024 Ⓒ Wormhole. All Rights Reserved.