Skip to main content

主网

提示

本页面介绍的接口,都是公开的方法,直接从 sdk 中导入即可使用。

1. 获取支持的所有公链#

const { readSnapshots } = require('mixin-node-sdk');readNetworkChains();
以下示例省掉引入的代码
[  {    "type": "chain",    "chain_id": "9c612618-ca59-4583-af34-be9482f5002d",    "name": "Akash",    "symbol": "AKT",    "icon_url": "https://mixin-images.zeromesh.net/96l-LTbahgBXnKfLRHtiQybyk9kpA-eVIMYnzs4twATFtIq3Ayvw5zRfhGrt5IOGqUxxJuFXINJMTNkRlWpnFVbsA4Ep6FAn0pWP=s128",    "managed_block_height": 7131973,    "deposit_block_height": 7131961,    "external_block_height": 7131973,    "threshold": 16,    "withdrawal_timestamp": "2022-08-11T04:29:30.196474272Z",    "withdrawal_pending_count": 0,    "withdrawal_fee": "2",    "is_synchronized": true  },  ...]

2. 获取 mixin 网络内转账记录#

readNetworkSnapshots();
tip
  1. 支持 limit/offset/asset/order 来进筛选和排序,如 readNetworkSnapshots({limit:10})
  2. order 的取值为 ascdesc,默认为 desc
[  {    "amount": "-0.21714313",    "asset": {      "asset_id": "43d61dcd-e413-450d-80b8-101d5e903357",      "asset_key": "0x0000000000000000000000000000000000000000",      "chain_id": "43d61dcd-e413-450d-80b8-101d5e903357",      "icon_url": "https://mixin-images.zeromesh.net/zVDjOxNTQvVsA8h2B4ZVxuHoCF3DJszufYKWpd9duXUSbSapoZadC7_13cnWBqg0EmwmRcKGbJaUpA8wFfpgZA=s128",      "mixin_id": "8dd50817c082cdcdd6f167514928767a4b52426997bd6d4930eca101c5ff8a27",      "name": "Ether",      "symbol": "ETH",      "type": "asset"    },    "created_at": "2022-08-11T04:32:26.424782Z",    "snapshot_id": "ad44da1c-23c5-47bc-8988-b5262d0b2571",    "source": "WITHDRAWAL_INITIALIZED",    "type": "snapshot"  },  ...]

3. 获取公共网络的转账记录。#

readExternalTransactions();
tip

参数同上

[  {    "type": "transaction",    "transaction_id": "2091583b-d114-4d82-902b-9dbaeab7ae37",    "transaction_hash": "0x765453a20ef37a8ef586f3ba5d3fe754dc08a8979cf93adc983ab13c172e991f",    "output_index": 1,    "sender": "0x0000000000000000000000000000000000000000",    "chain_id": "43d61dcd-e413-450d-80b8-101d5e903357",    "asset_id": "43d61dcd-e413-450d-80b8-101d5e903357",    "amount": "1.75",    "destination": "0xCD458d7F11023556cC9058F729831a038Cb8Df9c",    "tag": "",    "confirmations": 5,    "threshold": 16,    "created_at": "2022-08-11T04:35:49.826317471Z"  },  ...]

4. 获取 mixin 网络内资产排行#

readNetworkAssetsTop();
[  {    "type": "asset",    "asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",    "chain_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",    "symbol": "BTC",    "name": "Bitcoin",    "icon_url": "https://mixin-images.zeromesh.net/HvYGJsV5TGeZ-X9Ek3FEQohQZ3fE9LBEBGcOcn4c4BNHovP4fW4YB97Dg5LcXoQ1hUjMEgjbl1DPlKg1TW7kK6XP=s128",    "balance": "0",    "deposit_entries": null,    "destination": "",    "tag": "",    "price_btc": "1",    "price_usd": "24338",    "change_btc": "0",    "change_usd": "0.06414236369201172",    "asset_key": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",    "mixin_id": "fe6b7788944d328778f98e3e81588215b5a07de4f9a4a7de4db4535b404e65db",    "reserve": "0",    "confirmations": 3,    "capitalization": 319676541.15416884,    "liquidity": "13134.87308547"  },  ...]

5. 获取所有支持多重签名的资产列表#

readNetworkAssetsMultisig();
[  {    "type": "asset",    "asset_id": "002fa713-04f0-3642-b66e-e60a6a1aea41",    "chain_id": "43d61dcd-e413-450d-80b8-101d5e903357",    "symbol": "sMOB-pUSD",    "name": "4swap LP Token MOB-pUSD",    "icon_url": "https://mixin-images.zeromesh.net/0RykFlrn_82TX_hOuHLElmyDQQ7MRiFTlk5ZDd27Kgo9Z3-_pK-6fJKLsjA3bTJRHknmPegkYnffERnFCc3g28GFu5IVUOC_txQn=s128",    "balance": "0",    "deposit_entries": null,    "destination": "",    "tag": "",    "price_btc": "0.00011084",    "price_usd": "2.6976885",    "change_btc": "-0.0315845132622212",    "change_usd": "0.029902391027337143",    "asset_key": "0xfcd52ed967221d1ea330d27f60b9fd5fa66378d3",    "mixin_id": "3a6284fe32fc9c526f655acda11fff075c450610fd7755e1c63db46416e17b6e",    "reserve": "0",    "confirmations": 16,    "capitalization": 0,    "liquidity": "22566.29325789"  },  ...]

6. 根据 asset_id 获取资产详情#

readNetworkAsset(`965e5c6e-434c-3fa9-b780-c50f43cd955c`);
{  "amount": "99999318959201.52",  "asset_id": "965e5c6e-434c-3fa9-b780-c50f43cd955c",  "asset_key": "0xec2a0550a2e4da2a027b3fc06f70ba15a94a6dac",  "capitalization": 176370,  "chain_id": "43d61dcd-e413-450d-80b8-101d5e903357",  "change_btc": "-0.03190439299866356",  "change_usd": "-0.03575265921170372",  "confirmations": 16,  "fee": "0.005",  "icon_url": "https://mixin-images.zeromesh.net/0sQY63dDMkWTURkJVjowWY6Le4ICjAFuu3ANVyZA4uI3UdkbuOT5fjJUT82ArNYmZvVcxDXyNjxoOv0TAYbQTNKS=s128",  "liquidity": "99999318959201.52",  "mixin_id": "b9f49cf777dc4d03bc54cd1367eebca319f8603ea1ce18910d09e2c540c630d8",  "name": "Chui Niu Bi",  "price_btc": "0",  "price_usd": "0",  "reserve": "0",  "snapshots_count": 34019778,  "symbol": "CNB",  "type": "asset"}

7. 根据 symbol 或者 name 查找资产详情#

searchNetworkAsset('btc');
[  {    "type": "asset",    "asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",    "chain_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",    "symbol": "BTC",    "name": "Bitcoin",    "icon_url": "https://mixin-images.zeromesh.net/HvYGJsV5TGeZ-X9Ek3FEQohQZ3fE9LBEBGcOcn4c4BNHovP4fW4YB97Dg5LcXoQ1hUjMEgjbl1DPlKg1TW7kK6XP=s128",    "balance": "0",    "deposit_entries": null,    "destination": "",    "tag": "",    "price_btc": "1",    "price_usd": "24327",    "change_btc": "0",    "change_usd": "0.062407197135120974",    "asset_key": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",    "mixin_id": "fe6b7788944d328778f98e3e81588215b5a07de4f9a4a7de4db4535b404e65db",    "reserve": "0",    "confirmations": 3,    "capitalization": 319875816.94059694,    "liquidity": "0"  }]

8. 检测一个地址是否属于 mixin 主网#

readExternalAddressesCheck({  asset: '43d61dcd-e413-450d-80b8-101d5e903357',  destination: '0xCD458d7F11023556cC9058F729831a038Cb8Df9c',});
{  "destination": "0xCD458d7F11023556cC9058F729831a038Cb8Df9c",  "fee": "0",  "tag": ""}
提示

如果是属于 mixin 主网的,那么 fee 就是 0,否则的话就会显示对应的提现手续费。

9. 获取指定资产在指定时间的价格#

readNetworkTicker('43d61dcd-e413-450d-80b8-101d5e903357', '2018-08-11T04:32:26.424782Z');
{  "type": "ticker",  "price_btc": "0.05231160363869184632013147300366",  "price_usd": "322.291484932"}