Illia Polosukhin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # OmniToken Tech Spec ## Overview OmniToken is specification for bringing assets issued on NEAR to all chains using Chain Signatures. Technically this is simlar to Rainbow Bridge Token Connector design, expanding to supporting Chain Signature and other bridges as communication protocols. | Contract | VM | Description | | - | - | - | | omni-token-connector | NEAR | Omni token connector that locks/unlocks funds | | your-token | NEAR | any token supporting NEP-141 | | erc-20 | EVM | Extended erc20 to allow multichain transfer | | spl | Solana | Extending spl22? | ## Context Historically Rainbow Bridge only supported going between NEAR and Ethereum. This design proposes to expand Rainbow Bridge to OmniBridge: supporting bridging NEAR tokens to any chain supported by Chain Signatures and some cross-chain messaging protocol. As part of this proposal, we suggest to move Rainbow Bridge NEAR -> Ethereum to using this standard going forward. This offers a number of benefits: - No need for NEAR light client on Ethereum (cost reduction) - No need to wait for on Ethereum side for optimistic verification of light client (time reduction) ## Multichain transfer standard Address: `<chain-id>:<address>` Smart contract on NEAR maintains mapping between `<chain-id>` and specific way to resolve it to localize transaction. E.g. which VM it is and what is specific chain id in that VM (`eth:` is `EVM(1)`, `base:` is `EVM(8453)`, `near:` is `NEARVM`, `sol:` is `SVM`, etc) Relevant documents: - https://eips.ethereum.org/EIPS/eip-3770 - Vitalik's tweet mentioning unified addresses: https://x.com/VitalikButerin/status/1803459321423868298 ## Models There are two models we can support: - NEAR-first token - NEP-141 is the originating token - Foreign token - foreign token that gets first connected to NEAR - USDC - special case because of their [Bridged USDC Standard](https://www.circle.com/blog/bridged-usdc-standard) For new tokens contracts that support conditional mint/burn, this can enable supporting maintaing single total supply. ## Omni Token Connector ```rust! /// Smart contract handling locking NEAR tokens and emitting Chain Signatures to mint them on the other chain. /// If recevied request to withdraw, validates with a prover smart contract and struct OmniTokenConnector { prover_id: AccountId, signer_id: AccountId, chains: HashMap<String, ChainKind>, tokens: UnorderedMap<AccountId, Token>, } impl OmniTokenConnector { /// Adds chain alias. Only DAO. pub fn register_chain(&mut self, chain_alias: String, chain_kind: ChainKind); /// Register new token. /// Requires storage deposit to ensure Sybil resistance. pub fn register_token(&mut self, token_id: AccountId); /// Withdraw funds from connector to address provided in proof. /// Supports OmniAddress to withdrawing directly to another chain. pub fn withdraw(&mut self, chain_alias: String, proof: Vec<u8>); } impl OnFungibleTokenReceiveal for OmniTokenConnector { /// Handles ft_transfer_call from existing tokens to transfer to other chains. /// `msg` contains OmniAddress to which this tokens should be routed. fn ft_on_transfer(sender_id: AccountId, amount: Balance, msg: string) -> Balance } ``` Token information: ```rust! struct Token { /// Set of deployed chains. chains: HashSet<ChainKind>, /// Locked amount. Useful for checking internal consistency. locked_amount: Balance, } ``` ## OmniProver This is a prover that combines a number of different bridges to validate ```rust! struct BridgeMessage { token_id: OmniAddress, sender: OmniAddress, receiver: OmniAddress, amount: Balance, } enum BridgeKind { Raindbow = "rainbow.near", Wormhole = "wormhole.near", AuroraAxelar = "<address from aurora transport>", AuroraLayerZero = "<address from aurora transport>", MultisigOracle = "omni-token-oracle", } /// OmniProver serves a single end point to validate a proof from another chain across a vareity of different bridges. struct OmniProver { chains: UnorderedMap<ChainKind, BridgeKind>, } impl OmniProver { pub fn set_bridge pub fn validate_proof(self, chain_kind: ChainKind, message: bytes[]) -> Result<BridgeMessage, BridgeError>; } ``` ## Tooling Indexer Explorer ### Analytics What kind of analytics do we need? - Per token show all chains it's available on. NEAR chain > EVM NEAR chain > Solana EVM > NEAR chain Solana > NEAR chain EVM > EVM X chain to X chain Auction process: - anyone can submit a price -- interface needs to have max amount of fees - team will launch a relayer - or user can take an action or automatic cancel fee oracle in contract from market makers # Integrations & Support We need to make sure: - Centralized exchanges are comfortable with these tokens - Wallet and exchanges supporting OmniToken API - ## Appendix High level decisions: Decision 1: - using Rainbow’s design for TokenConnector to send/receive funds on another chain. (See implementation - https://github.com/Near-One/rainbow-token-connector / https://github.com/Near-One/rainbow-token-connector/blob/master/token-locker/src/lib.rs) - Pros: supports existing NEAR tokens, supports existing Rainbow approach. we have already A frontend for this. We don't need to extend Ethereum/Solana contracts - they also just send it to the respective Connector contract on remote chain / calling a method that does `transferFrom`. Instead of passing NEAR address or EVM address we use `OmniAddress` - Cons: mostly positioning as OmniToken in this case vs reality as it's not modifying the token standard - Use Prover to aggregate a number of different bridge/message passing protocols. We are going to make it upgradable. - Pros: we can launch with Prover just supporting Eth light client state prover and extend with others later. If there are multiple chains - Cons: maintaining multiple bridges integrations can become expensive as they change things. For new chains there is no bridge. Decision 2: - add new methods to NEP-141/ERC-20 to allow to send multichain transfers: `ft_ca_transfer(receiver: OmniAddress, amount: Balance, max_fee: Balance)` and `erc3770_transfer(string _receiver, uint256 _value, uint256 _max_fee)` - these methods can call into TokenConnector or have implementation direclty in the contract (not recommended) - Pros: actually makes a feel of OmniToken. Can be working with Token Connector format in tandem. - Cons: doesn't work with existing tokens. Standard is hard to stabilize on our timeline. > Alternative - API interface instead of ABI. Can be a library that everyone can use that supports on different chains? - Pros: no changes to existing projecs - Cons: potentially hard to coordinate implementation but mitigatable with quality library ## Outdated ### NEAR interface We extend NEP-141 with ability to `ft_transfer` to an address on another chain. For backward compatibility with existing tokens, one can do `ft_transfer_call` to the `omni-token-factory` by calling a method that will transfer to another chain. ```rust /// Supports defaulting to NEAR when provided without ":" type OmniAddress = String; ... fn ft_transfer(account_id: OmniAddress) ``` Question: - do we want to burn the tokens on NEAR or just park them in the `omni-token-factory` -- this is compatible with Connector. ### EVM interface We extend ERC-20 standard with a new transfer method that supports `OmniAddress` to allow to transfer to other chains. ```solidity /// `_to` is OmniAddress in the format `<chain>:<address>`. function ft_transfer(string _to, uint256 _value) public returns (bool success) /// Receive funds across chains to a given address with given value. /// Can be only called by owner of the contract. function ft_on_transfer(string _to, uint256 _value) onlyOwner() return () ``` ### SVM interface ```rust TODO ``` ### Other Functionality: - creating contracts on other chains - holds EOAs of other chains that control mint/burn of those accounts via Chain Signatures - sends messages to EVM, SVM, etc to mint new tokens on request - register new omni token if it was created outside of factory scope - bridge aggregation to receive messages back from other chains - wraps existing NEAR tokens to make them omni tokens (e.g. handles `ft_transfer_call` to send to another chain) ```rust /// Chain kind of executing enum ChainKind { NEAR, EVM(chainId), SVM, } /// Standard for OmniAddresses, must be <chain>:<address> type OmniAddress = string; ``` Omni Token Factory serves as a bridge aggregator. Bridge aggregator supports next functionality: - Maintains list of all accessible read bridges on NEAR. - Able to parse specific bridge messages into specific instructions for tokens. Returns which token/network and who transferred to whom. ```rust struct BridgeMessage { token_id: OmniAddress, sender: OmniAddress, receiver: OmniAddress, amount: Balance, } enum BridgeKind { Raindbow = "rainbow.near", Wormhole = "wormhole.near", AuroraAxelar = "<address from aurora transport>", AuroraLayerZero = "<address from aurora transport>", MultisigOracle = "omni-token-oracle", } /// Serves as a bridge aggregator struct BridgeManager { } impl BridgeManager { fn fetch_state(self, bridge_kind: BridgeKind); fn parse_bridge_message(self, predecessor_id: AccountId, message: bytes[]) -> Result<BridgeMessage, BridgeError>; } ``` ```rust /// Information about the given token. struct TokenInfo { /// Owned is true when token was created by the factory. owned: bool, bridged_amount: Balance, /// Contians set of all networks where remote contracts have been deployed. networks: HashMap<ChainId, OmniAddress>, } struct OmniTokenFactory { bridge_manager: BridgeManager, tokens: LookupMap<AccountId, TokenInfo>, } impl OmniTokenFactory { /// Register existing token. fn register_token(self, token_id: AccountId); /// Add support for given network for provided token fn add_network(self, token_id: AccountId, chain_id: ChainId); /// Internal method to create transfer transaction and sending it to Chain Signatures. /// Validates that given token has added given network. fn internal_transfer(self, token_id: AccountId, receiver: OmniAddress, amount: Balance); /// TODO: Actually may be not worse doing and keep only on_ft_ /// Protected methods to only tokens that are created via factory. Predecessor must be registered token. /// If validated, calls `self.internal_transfer` fn on_ft_transfer(self, chain_id: ChainId, receiver: OmniAddress, amount: Balance); /// Gets called when bridged information arrives. /// Passes to BridgeManager for parsing. fn on_bridged(self, message: bytes[]); } impl OnFungibleTokenReceiveal for OmniTokenFactory { /// Handles ft_transfer_call from existing tokens to transfer to other chains. fn ft_on_transfer(sender_id: AccountId, amount: Balance, msg: string) -> Balance { /// Handles tokens which are not created by the factory. /// If validated, calls `self.internal_transfer()` based on the message parsed into OmniAddress of receiver. } } ``` ## Other https://docs.layerzero.network/v2/home/token-standards/oft-standard https://docs.wormhole.com/wormhole/native-token-transfers/overview

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully