Vizing Docs
HomeExplorerBridgeEcosystem
  • 📖Introduction
  • Ready to launch
    • 🏗️Architecture
    • 🌉Cross-Chain DApps
    • 🔒Security Model
    • 🌱Lifecycle of a Message
  • Build on Vizing
    • 💻Development Environment
    • 🛠️Integrating Vizing Core Contracts
    • 🎨Brand Kit
  • Explore OmniDApp
    • 🧑‍🎨Omni-NFT
    • 💰Omni-Fungible-Token
    • 📝Omni-Inscriptions
    • 🪙Omni-ERC20-Transfer
    • 🔮Omni-Runes
  • Bridge Assets On Vizing
    • 💵Bridge Protocol
    • 🍳Cook Book
    • 🌏OPEN API
    • 🔀Router Contract
    • 🧰Utils
Powered by GitBook
On this page

Was this helpful?

  1. Bridge Assets On Vizing

Utils

PreviousRouter Contract

Last updated 6 months ago

Was this helpful?

string to hex

export const toHex = (str: string): string => {
    const encoder = new TextEncoder();
    const value = encoder.encode(str);
    const hexes = Array.from({ length: 256 }, (_v, i) =>
      i.toString(16).padStart(2, '0'),
    );

    let string = '';
    for (let i = 0; i < value.length; i++) {
      string += hexes[value[i]];
    }
    const hex = `0x${string}` as const;
    return hex;
  }
🧰
​