MAPO Developer Docs
LearnDevelopRunWhitePaperBRC-201
繁體中文
繁體中文
  • 概述
  • 學習
    • 關於 MAP 協議
      • 背景
      • 介紹 MAP 協議
      • MAP 協議的發展歷程
    • 與其他跨鏈模型進行比較
      • MAP 協議與Cosmos& Pokadot
      • MAP vs. 其他無中繼鏈的跨鏈解決方案
    • 技術機制
      • MAP協議'的技術機制
      • 三層結構
      • MAP協議層
      • MAP中繼鏈
        • 概念
        • 與所有鏈的同構性
        • 驗證& 維護網絡
      • MAPO服務(MOS)層
      • MAPO應用層
      • ZK 支持下的輕節點
    • 燃氣費收費模式
    • DAO
    • MAP協議的構建
      • 開發者
      • 驗證者
      • 維護者
      • 信使
      • 流動資金提供者
      • 終端用戶
    • Tokenomics
    • 購買$MAP
  • 開發
    • MAP Relay Chain
      • 入門
        • 構建
        • 製作私有鏈
        • 如何投票
        • 如何取出質押
        • 集成到交易所
        • EVM 兼容鏈接入MAP 中繼鏈
      • 共識
        • 概述
        • Proof-of-Stake
        • 驗證器
          • 驗證器
          • 鎖定的MAP
        • 選舉
        • 獎勵
        • 聚合印章
      • 合約
        • 預編譯合約
        • 創世紀合約
          • ABI
            • AccountsABI
            • ElectionABI
            • EpochRewardsABI
            • LockedGoldABI
            • ValidatorsABI
          • Deploy
      • Marker
        • Genesis
        • 驗證器
        • Vote
        • ContractOwner
        • Common
    • 輕型客戶端
      • 基於輕型客戶端的驗證
      • MAPO輕型客戶端
        • EVM鏈
        • Near
      • 輕客戶端
        • 客戶端管理器
        • BNB 鏈
        • NEAR 協議
        • Polygon(Matic)
        • Ethereum 2.0
        • 維護者
    • MOS 全鏈服務
      • MOS消息指南
        • How It Works
      • MOS 指南
        • 運行原理
        • 如何使用
          • 在Evm鏈的方法
          • 在NEAR協議上
        • 中繼鏈合約
        • EVM鏈合約
        • NEAR 協議合約
      • 信使
      • API
    • OmniChain實例
      • Omni App
      • OmniDictionary
    • API & SDK
      • Butter SDK
      • Atlas JSON RPC
      • Atlas Consensus API
      • MAP掃描API
    • 最新接鏈進展以及對應地址
  • 運行
    • 如何成爲一個新的驗證者
    • 如何成爲一個新的驗證者[進階版]
    • 取出或撤回
Powered by GitBook
On this page
  • 合約地址
  • 合約界面
  • 與合約接口交互
  • 轉入
  • transfer_out_token
  • transfer_out_native
  • deposit_out_native
  • 管理界面
  • 初始化
  • 版本
  • deploy_mcs_token
  • is_used_event
  • set_metadata
  • 控制帳戶 controller
  • set_controller
  • controller_or_self
  • get_mcs_tokens
  • get_fungible_tokens
  • get_native_token_to_chains
  • add_native_to_chain
  • remove_native_to_chain
  • add_mcs_token_to_chain
  • remove_mcs_token_to_chain
  • valid_mcs_token_out
  • add_fungible_token_to_chain
  • remove_fungible_token_to_chain
  • valid_fungible_token_out
  • 數據結構
  • 以下是地圖燈客戶端合約的一些主要數據結構。

Was this helpful?

  1. 開發
  2. MOS 全鏈服務
  3. MOS 指南

NEAR 協議合約

PreviousEVM鏈合約Next信使

Last updated 1 year ago

Was this helpful?

合約地址

合約界面


impl MapCrossChainService {
    pub fn init(map_light_client: String, map_bridge_address: String, wrapped_token: String, near_chain_id: u128) -> Promise;

    pub fn version() -> &'static str;

    #[payable]
    pub fn transfer_in(&mut self, receipt_proof: ReceiptProof, index: usize) -> Promise;

    pub fn transfer_out_token(&mut self, token: String, to: Vec<u8>, amount: U128, to_chain: u128) -> Promise;

    #[payable]
    pub fn transfer_out_native(&mut self, to: Vec<u8>, to_chain: u128) -> Promise;

    #[payable]
    pub fn deposit_out_native(&mut self, to: Vec<u8>);

    #[payable]
    pub fn deploy_mcs_token(&mut self, name: String) -> Promise;

    pub fn is_used_event(&self, order_id: &CryptoHash) -> bool;

    pub fn set_metadata(
        &mut self,
        address: String,
        name: Option<String>,
        symbol: Option<String>,
        reference: Option<String>,
        reference_hash: Option<Base64VecU8>,
        decimals: Option<u8>,
        icon: Option<String>,
    ) -> Promise;

    pub fn controller(&self) -> Option<AccountId>;

    pub fn set_controller(&mut self, controller: AccountId);

    pub fn controller_or_self(&self) -> bool;

    pub fn get_mcs_tokens(&self) -> Vec<(String, HashSet<u128>)>;

    pub fn get_fungible_tokens(&self) -> Vec<(String, HashSet<u128>)>;

    pub fn get_native_token_to_chains(&self) -> HashSet<u128>;

    pub fn add_native_to_chain(&mut self, to_chain: u128);

    pub fn remove_native_to_chain(&mut self, to_chain: u128);

    pub fn add_mcs_token_to_chain(&mut self, token: String, to_chain: u128);

    pub fn remove_mcs_token_to_chain(&mut self, token: String, to_chain: u128);

    pub fn valid_mcs_token_out(&self, token: &String, to_chain: u128) -> bool;

    pub fn add_fungible_token_to_chain(&mut self, token: String, to_chain: u128) -> PromiseOrValue<()>;

    pub fn remove_fungible_token_to_chain(&mut self, token: String, to_chain: u128);

    pub fn valid_fungible_token_out(&self, token: &String, to_chain: u128) -> bool;
}

與合約接口交互

轉入

根據證明數據和事件從 Mapo 轉移到 Near。 必須附加足夠的 NEAR 資金來支付證明的存儲費用。

輸入參數

參數
類型
備註

receipt_proof

ReceiptProof

the proof of one receipt

index

usize

the index of event among all the events in the receipt

transfer_out_token

Transfer out tokens to other blockchain.

輸入參數

參數
類型
備註

token

String

NEAR account of the mcs token contract

to

Vec

the target account address on target blockchain

amount

U128

the amount of token to transfer out

to_chain

u128

the chain id of target blockchain

transfer_out_native

Transfer out native token to other blockchain.

輸入參數

參數
類型
備註

to

Vec

the target account address on target blockchain

to_chain

u128

the chain id of target blockchain

deposit_out_native

Deposit out native token to MAP blockchain.

輸入參數

參數
類型
備註

to

Vec

the target account address on MAP blockchain

管理界面

初始化

使用配置參數初始化合約。

輸入參數

參數
類型
備註

map_light_client

String

MAP 輕客戶端合約的 NEAR 賬戶

map_bridge_address

String

MOS 合約在 MAP 區塊鏈上的十六進制地址

wrapped_token

String

wrap near 合約的 NEAR 賬戶

near_chain_id

u128

NEAR 區塊鏈的鏈ID

版本

獲取當前 MCS 合約的版本信息。

deploy_mcs_token

部署 MOS 代幣合約。 部署的代幣可以由 MOS 合約鑄造/銷毀。

輸入參數

參數
類型
備註

name

String

MOS代幣的名稱,代幣的完整地址為<名稱>.<MOS合約地址>

is_used_event

檢查事件是否被使用。

輸入參數

參數
類型
備註

order_id

&CryptoHash

event事件的訂單id

輸出參數

type
comment

bool

如果事件已被使用,則為 true,否則為 false

set_metadata

獲取指定紀元的記錄信息(驗證者、閾值和紀元)。

輸入參數

參數
類型
備註

address

String

MOS 代幣合約地址

name

Option

代幣可讀名字

symbol

Option

略縮形式例如wETH 或者 AMPL

reference

Option

指向包含各種密鑰的有效 JSON 文件的鏈接,提供有關令牌的補充詳細信息

reference_hash

Option

引用字段中包含的 JSON 文件的 base64 編碼的 sha256 哈希

decimals

Option

在前端用於顯示令牌的正確有效數字

icon

Option

與此代幣關聯的頭像

控制帳戶 controller

獲取MOS 合約的控制帳戶 ID

輸出參數

類型
備註

Option

MOS 合約的控制帳戶 ID

set_controller

設置 MCS 合約的控制帳戶。

輸入參數

參數
類型
備註

controller

AccountId

MOS 合約的控制帳戶 ID

controller_or_self

檢查前任是控制者還是自己。

輸出參數

type
comment

bool

如果前任是控制者或自己,則為 true,否則為 false

get_mcs_tokens

獲取已部署的所有MOS代幣和其目標鏈

輸出參數

type
comment

Vec<(String, HashSet)>

已部署的MOS代幣和其目標鏈

get_fungible_tokens

獲取所有可置換代幣和其目標鏈

輸出參數

type
comment

Vec<(String, HashSet)>

已註冊可置換代幣和其目標鏈

get_native_token_to_chains

獲取所有已註冊的本地代幣目標鏈。

輸出參數

類型
備註

HashSet

註冊原生代幣目標鏈

add_native_to_chain

為原生代幣添加目標鏈。

輸入參數

參數
類型
備註

to_chain

u128

目標鏈 id

remove_native_to_chain

刪除本地代幣的目標鏈。

輸入參數

參數
類型
備註

to_chain

u128

目標鏈 id

add_mcs_token_to_chain

允許 MOS 代幣轉移到目標鏈。

輸入參數

參數
類型
備註

token

String

MOS代幣地址

to_chain

u128

目標鏈 id

remove_mcs_token_to_chain

從 MOS 代幣的允許列表中刪除目標鏈 ID。

輸入參數

參數
類型
備註

token

String

MOS代幣地址

to_chain

u128

目標鏈 id

valid_mcs_token_out

檢查是否允許將代幣轉移到目標鏈。

輸入參數

參數
類型
備註

token

&String

MOS代幣地址

to_chain

u128

目標鏈 id

輸出參數

類型
備註

bool

如果允許目標鏈,則為 true,否則為 false

add_fungible_token_to_chain

允許將可置換代幣轉移到目標鏈。

輸入參數

參數
類型
備註

token

String

可置換代幣的地址

to_chain

u128

目標鏈 id

remove_fungible_token_to_chain

從可替代代幣的允許列表中刪除目標鏈 ID。

輸入參數

參數
類型
備註

token

String

可置換代幣的地址

to_chain

u128

目標鏈 id

valid_fungible_token_out

檢查是否允許將代幣轉移到目標鏈。

輸入參數

參數
類型
備註

token

&String

MOS 代幣地址

to_chain

u128

目標鏈 id

輸出參數

類型
備註

bool

如果允許目標鏈,則為 true,否則為 false

數據結構

以下是地圖燈客戶端合約的一些主要數據結構。

MapCrossChainService 是地圖跨鏈服務合約。


pub struct MapCrossChainService {
    /// The account of the map light client that we can use to prove
    pub map_client_account: AccountId,
    /// Address of the MAP bridge contract.
    pub map_bridge_address: Address,
    /// Set of created MCSToken contracts.
    pub mcs_tokens: UnorderedMap<String, HashSet<u128>>,
    /// Set of other fungible token contracts.
    pub fungible_tokens: UnorderedMap<String, HashSet<u128>>,
    /// Map of other fungible token contracts and their min storage balance.
    pub fungible_tokens_storage_balance: UnorderedMap<String, u128>,
    /// Map of token contracts and their decimals
    pub token_decimals: UnorderedMap<String, u8>,
    /// Set of other fungible token contracts.
    pub native_to_chains: HashSet<u128>,
    /// Hashes of the events that were already used.
    pub used_events: UnorderedSet<CryptoHash>,
    /// Public key of the account deploying the MCS contract.
    pub owner_pk: PublicKey,
    /// Balance required to register a new account in the MCSToken
    pub mcs_storage_transfer_in_required: Balance,
    // Wrap token for near
    pub wrapped_token: String,
    // Near chain id
    // FIXME: get from env?
    pub near_chain_id: u128,
    // Nonce to generate order id
    pub nonce: u128,
    /// Mask determining all paused functions
    paused: Mask,
}

ReceiptProof包括證明和收據證明。

pub struct ReceiptProof {
    // the block header where the receipt exists
    pub header: Header,
    // the aggregated G2 public key of the signed validators
    pub agg_pk: G2,
    // the receipt to prove
    pub receipt: Receipt,
    // the index of the receipt in the block
    pub key_index: Vec<u8>,
    // the proof to prove the existance of the above receipt
    pub proof: Vec<ProofEntry>,
}
此處獲取MAPO主網和測試網MCS合約地址。
MOS