npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hashflow/contracts-evm

v2.0.12

Published

EVM Smart Contracts for Solidity

Downloads

2,291

Readme

Hashflow EVM Protocol

This package contains Solidity Smart Contract code for the Hashflow protocol. This code is compatible with EVM chains (e.g. Ethereum, Arbitrum).

Compiling the code:

yarn hardhat compile

Running unit tests:

yarn hardhat test

Initializing the Wormhole Messenger

Contract Deployment

The HashflowWormholeMessenger contract takes the following two parameters for deployment:

  • the Hashflow Chain ID (this is different from the EVM Chain ID and the Wormhole Chain ID)
  • the HashflowRouter address on the specific chain

Hashflow Chain IDs should be configured as such:

| Chain | Hashflow Chain ID | | --------------- | ----------------- | | Ethereum | 1 | | Arbitrum | 2 | | Optimism | 3 | | Avalanche | 4 | | Polygon | 5 | | BSC | 6 | | Solana | 30 | | Ethereum Goerli | 101 | | Polygon Mumbai | 103 | | BSC Testnet | 104 | | Solana Devnet | 130 |

The wormhole-messenger:deploy task can be used to deploy the contract.

Initializing the Wormhole Endpoint

Every Wormhole message is created by making a call to an endpoint contract deployed by Wormhole. The address of the endpoint contract for each chain is as follows:

| Chain | Wormhole Endpoint | | --------------- | ------------------------------------------ | | Ethereum | 0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B | | Arbitrum | 0xa5f208e072434bC67592E4C49C1B991BA79BCA46 | | Optimism | 0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722 | | Avalanche | 0x54a8e5f9c4CbA08F9943965859F6c34eAF03E26c | | Polygon | 0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7 | | BSC | 0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B | | Ethereum Goerli | 0x706abc4E45D419950511e474C7B9Ed348A4a716c | | Polygon Mumbai | 0x0CBE91CF822c73C2315FB05100C2F714765d5c20 | | BSC Testnet | 0x68605AD7b15c732a30b1BbC62BE8F2A509D74b4D |

The wormhole-messenger:initialize:wormhole task can be used to initialize the Wormhole contract.

Initializing the Consistency Level

Wormhole Guardians use the consistency level to determine when to emit the VAA. Different consistency levels come with different risks / guarantees. We set the consistency levels to the safest possible values in order to avoid running the risk of re-orgs.

For the following chains, safe levels are often too long for a good user experience:

  • Ethereum
  • Polygon

For those chains, we set a "fast" consistency level, which emits VAAs much faster, while running the risk of re-orgs.

In order to mitigate that risk, relaying "fast" messages is only possible via specific relayers, which are configured at the contract level. These relayers use heuristics to decide which messages are safe to relay faster than usual.

Relaying regular ("slow") messages can be done by anyone.

The wormhole-messenger:initialize:consistency task can be used to initialize the consistency level.

The wormhole-messenger:initialize:fast-consistency task can be used to initialize the "fast" consistency level.

Initializing the Hashflow <-> Wormhole Chain ID mapping

Hashflow Chain IDs differ from Wormhole Chain IDs. This is because Hashflow is agnostic to the interoperability protocol it uses under the hood (i.e. Wormhole).

In order to properly send cross-chain trades, we need to initialize the mapping between Hashflow and Wormhole Chain IDs for both the current chain and its peer chains.

The wormhole-messenger:initialize:chain-id-mapping task can be used to initialize these mappings.

Initializing Remotes

The messenger needs to know what its peers (remotes) on other chains are. This is very important when verifying the messages it receives. Only authenticated senders should be allowed to communicate with this messenger.

Remotes are updated based on their Hashflow Chain ID (and NOT Wormhole Chain ID). Their addresses must be prepended with 0 bytes up to 32 bytes. This is especially important for EVM remote addresses, which are 20 bytes on their native chains.

The wormhole-messenger:initialize:remotes task can be used to initialize the remotes.