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

@mapprotocol/mos

v0.4.1

Published

MAP Protocol omnichain messaging service.

Downloads

82

Readme

MOS Message Contracts

MOS message is a MOS(MAP Omnichain Service), MAP Protocol omnichain messaging service, it enables DApp built on one chain to easily interoperate other chains.

MOS Message

With MOS message you can achieve interoperation with two chains:

  • Call a contract on chain B from chain A.
  • Pack the message changes in chain A and write them into chain B to realize message synchronization

For examples built on MOS message, visit omnichain examples.

MAP Omnichain Service

MAP Protocol is the omnichain layer of Web3, a cross-chain interoperable protocol to empower Web3 apps to thrive in the omnichain future.

MAP Omnichain Service (MOS) provides common modules needed by cross-chain DApps to further lower the threshold of building cross-chain DApps with MAP protocol.

Illustration of MAP Protocol's MAP Omnichain Service (MOS) Layer

Visit docs for more MOS information.

Installation

npm install --save-dev @mapprotocol/mos
# or
yarn add --dev @mapprotocol/mos

Instruction

MapoServiceV3 contract is suitable for evm-compatible chains and implements cross-chain logic

MapoServiceRelayV3 contract implements cross-chain logic and basic cross-chain control based on MAP Relay Chain

FeeService contract is used to manage cross-chain fees.

Build

Copy file .env.example to .env and configure:

  • PRIVATE_KEY - User-deployed private key
  • INFURA_KEY - User-deployed infura key
  • MOS_SALT - User-deployed mos contract salt
  • FEE_SALT - User-deployed fee service contract salt
  • DEPLOY_FACTORY - Factory-contract address
git clone https://github.com/mapprotocol/mapo-service-contracts.git
cd mapo-service-contracts/evm
npm install

Test

npx hardhat test

Deploy

MOS Relay Contract

The following steps help to deploy MOS Relay contracts on MAP Relay Chain.

  1. Deploy Message fee
npx hardhat feeFactoryDeploy --network <network>
  1. Deploy MOS Relay
npx hardhat relayFactoryDeploy --wrapped <wrapped token> --lightnode <lightNodeManager address> --network <network>
  • wrapped token is wrapped MAP token address on MAPO Mainnet or Makalu testnet.
  • lightNodeManager address is the light client manager address deployed on MAP mainnet or MAP Makalu. See here for more information.
  1. Init MOS Relay
npx hardhat setFeeService  --address <message fee service address> --network <network>

MOS on EVM Chains

  1. Deploy
npx hardhat mosFactoryDeploy --wrapped <native wrapped address> --lightnode <lightnode address> --network <network>
  1. Set MOS Relay Address The following command on the EVM compatible chain
npx hardhat mosSetRelay --relay <Relay address> --chain <map chainId> --network <network>
  1. Init MOS
npx hardhat setFeeService  --address <message fee service address> --network <network>

Configure

Register

  • Register an EVM compatiable chain
npx hardhat relayRegisterChain --address <MOS address> --chain <chain id> --network <network>
  • Register a non-EVM chain
npx hardhat relayRegisterChain --address <MOS address> --chain <near chain id> --type 2 --network <network>

notice Now non-evm chain only support Near Protocol.

Set message fee

npx hardhat setMessageFee --chainid <to chain id> --base <Cross-chain base limit>  --price <gas price> --tokenaddress <The default is native token, can be filled in token address> --network <network>

In the FeeService mechanism, there will be base baseGas and a different chainGasPrice for each chain, which is the basis for determining how much Fee to charge for each cross chain.

The cross-chain fee calculation:

(baseGas + gasLimit) * chainGasPrice

gasLimit is determined by the user who calls the transferOut method and is at least 21000 and at most 10000000

Upgrade

When upgrade the mos contract through the following commands.

Please execute the following command on the EVM compatible chain

npx hardhat deploy --tags MapoServiceV3Up --network <network>

Please execute the following command on relay chain mainnet or Makalu testnet

npx hardhat deploy --tags MapoServiceRelayV3Up --network <network>

Message cross-chain transfer

  1. transfer out
npx hardhat transferOut  --target <to chain target address> --calldata <call data> --chain <to chain id> --network <network>