mintbase介绍

  • 利用mintbase的nft工厂合约(下一代nft引擎)部署一个NFT合约,这是消除中央不良行为者信任的基础和起点。

  • 在这个智能合约上铸造NFT。有各种规则,例如更改合同的所有权、造币厂、任何销毁。如果 Mintbase明天死亡,而您的代币可以继续存在。

  • 添加其他艺术家、同事、业务合作伙伴作为铸币工,推动运行自己的 dapp,部署商店后,实际上可以在 Dappradar上将其列为独立应用程序。

  • 为什么选择near?

    • https://medium.com/mintbase/scaling-mintbase-with-near-503375d92702
  • 为什么选择arweave?

    • https://medium.com/mintbase/mintbase-arweave-9459f3889c79
    • NFT 元数据和图像存储在arweave
    • 类似filecoin的去中心化分布式存储
  • 为什么不选择ipfs?

    • 1.上传时间长,用户体验差
    • 2.数据可能丢失(必须使用Piñata这样的服务商pin住数据)
  • Mintbase整个Ui通过TheGraph驱动,当用户与区块链进行交互时,TheGraph会记录购买、转移和铸造等事件。

TheGraph 介绍

  • The Graph网络对Web3的查询层和API层进行了去中心化,消除了dApp开发者目前面临的取舍难题:到底是开发一个高性能应用,还是开发一个完全去中心化的应用。

  • 目前,开发者可以在自己的基础架构上运行一个Graph节点,也可以在我们的托管服务上开发一个。其中,开发者构建和部署从Web3数据源提取数据并为其编制索引的子图。目前已经有许多领先的以太坊项目创建了子图,包括Uniswap、ENS、DAOstack、Synthetix和Moloch等。在The Graph网络中,任何索引器都能够通过抵押Graph代币(GRT)参与到网络中,并在提供查询服务的过程赚取费用和通货膨胀奖励。

  • 用户则按照使用次数进行付费,使用日益增长的索引器,此做法证明了供需规律也适用于该协议提供的服务。

  • TheGraph根据subgraph描述(称为subgraph清单)了解什么以及如何索引以太坊数据。subgraph描述定义了subgraph感兴趣的智能合约、这些合约中要注意的事件,以及如何将事件数据映射到 The Graph 将存储在其数据库中的数据。

near mintbase nft_3d

  1. 去中心化应用程序通过智能合约上的交易向以太坊/near添加数据。
  2. 智能合约在处理交易时发出一个或多个事件。
  3. Graph节点不断扫描以太坊以寻找新块以及它们可能包含的子图数据。
  4. Graph节点在这些块中为您的子图查找以太坊事件并运行您提供的映射处理程序。映射是一个 WASM 模块,它创建或更新 Graph Node存储的数据实体以响应以太坊事件。
  5. 去中心化应用程序使用节点的GraphQL 端点向 Graph 节点查询从区块链索引的数据。Graph Node 反过来将 GraphQL 查询转换为其底层数据存储的查询,以获取这些数据,利用存储的索引功能。去中心化应用程序在丰富的用户界面中为最终用户显示这些数据,他们使用这些用户界面在以太坊上发布新交易。循环重复。

部署 store

还有调用google faas服务、币安api查询币价
store=nft智能合约=dapp

google api /google serverless请求

  1. https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=AIzaSyAwZOiBAke2iUnLPp-hf4-uUKbL6lhaY0I
    返回值
{
    "kind": "identitytoolkit#GetAccountInfoResponse",
    "users": [
        {
            "localId": "d6eee505-96be-52b9-bcad-07df1d21cb75",
            "lastLoginAt": "1634137850898",
            "createdAt": "1633941694395",
            "customAuth": true,
            "lastRefreshAt": "2021-10-13T15:10:50.898Z"
        }
    ]
}
  1. https://us-central1-omni-live.cloudfunctions.net/developer
    返回值
{
  "BASE_ARWEAVE_URI": "https://arweave.net",
  "API_VERSION": "1",
  "API_BASE_NEAR_TESTNET": "https://mintbase-testnet.hasura.app/",
  "API_BASE_NEAR_MAINNET": "https://mintbase-mainnet.hasura.app/",
  "FACTORY_CONTRACT_NAME": "mintspace2.testnet",
  "MARKET_ADDRESS": "market.mintspace2.testnet"
}
  1. https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?xx

the graph api请求

  1. 获取当前账户所有store
    https://mintbase-testnet.hasura.app/v1/graphql
    {
    “operationName”: “GetAccountStores”,
    “variables”: {
    “id”: “kkst.testnet”
    },
    “query”: “query GetAccountStores($id: String!) {\n store(where: {minters: {account: {_eq: $id}}}, order_by: {createdAt: desc}, limit: 100) {\n id\n name\n createdAt\n tokens {\n id\n __typename\n }\n __typename\n }\n}\n”
    }
  2. 检查name
    https://mintbase-testnet.hasura.app/v1/graphql
{
    "operationName": "CheckStore",
    "variables": {
        "name": "tty"
    },
    "query": "query CheckStore($name: String!) {\n  store(where: {name: {_eq: $name}}) {\n    id\n    __typename\n  }\n}\n"
}
  1. 获取store及store里的token(部署store成功后)
    https://mintbase-testnet.hasura.app/v1/graphql
    {
    “operationName”: “GET_STORE_AND_OWNED_TOKENS”,
    “variables”: {
    “id”: “tty.mintspace2.testnet”,
    “account”: “kkst.testnet”
    },
    “query”: “query GET_STORE_AND_OWNED_TOKENS($id: String!, $account: String!) {\n store(where: {id: {_eq: $id}}, distinct_on: [reference]) {\n name\n owner\n createdAt\n things {\n id\n metaId\n storeId\n metadata {\n title\n description\n media\n media_hash\n animation_hash\n animation_url\n youtube_url\n document\n document_hash\n extra\n external_url\n category\n type\n visibility\n media_type\n animation_type\n tags\n media_size\n animation_size\n __typename\n }\n store {\n id\n name\n symbol\n owner\n is_external_contract\n __typename\n }\n tokens_aggregate(where: {ownerId: {_eq: $account}, burnedAt: {_is_null: true}}) {\n aggregate {\n count\n __typename\n }\n __typename\n }\n tokens(where: {burnedAt: {_is_null: true}, _and: {ownerId: {_eq: $account}}}, limit: 50) {\n id\n ownerId\n minter\n royaltys {\n percent\n account\n __typename\n }\n splits {\n percent\n account\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n”
    }

near rpc请求

  1. 获取账户信息
 {
    "method": "query",
    "params": [
        "account/kkst.testnet",
        ""
    ]
}
  1. 获取access key
 {
    "method": "query",
    "params": [
        "access_key/kkst.testnet",
        ""
    ]
}
  1. 获取区块数据
{
    "method": "block",
    "params": {
        "finality": "final"
    }
}
  1. 获取chain 配置
 {
    "method": "EXPERIMENTAL_protocol_config",
    "params": {
        "finality": "final"
    }
}

5.发送交易(同步方法)

 {
    "method": "broadcast_tx_commit",
    "params": [
        "DAAAAGtrc3QudGVzdG5ldACCpA75hIIUGllFDSzSuPrtaP8IKMzw7ErXP+4PvHpHq9RJvFhoPAAAEgAAAG1pbnRzcGFjZTIudGVzdG5ldPpSY7gFZ1FtZPSOhGRLpjVaX8MZN858jZohjwRrPEfQAQAAAAIMAAAAY3JlYXRlX3N0b3Jl0wAAAHsib3duZXJfaWQiOiJra3N0LnRlc3RuZXQiLCJtZXRhZGF0YSI6eyJzcGVjIjoibmZ0LTEuMC4wIiwibmFtZSI6Im5ldCIsInN5bWJvbCI6Im5ldCIsImljb24iOiJkYXRhOmltYWdlL3BuZztiYXNlNjQsUjBsR09EbGhBUUFCQUFBQUFDdz0iLCJiYXNlX3VyaSI6Imh0dHBzOi8vYXJ3ZWF2ZS5uZXQiLCJyZWZlcmVuY2UiOm51bGwsInJlZmVyZW5jZV9oYXNoIjpudWxsfX0AgPQg5rUAAAAAgJYINMC0bWAFAAAAAAAAb2FsVhkkkCRzTSJOEN5kAd2+uAsSpbs9XaCuyMyRZDGiheR9piXWzhSytnU8bIZXJ7rTIKaOre7UN+VSZme+Ag=="
    ]
}  

调用了mintspace2.testnet的create_store方法,params参数如下,点击查看tx

{
  "owner_id": "kkst.testnet",
  "metadata": {
    "spec": "nft-1.0.0",
    "name": "net",
    "symbol": "net",
    "icon": "data:image/png;base64,R0lGODlhAQABAAAAACw=",
    "base_uri": "https://arweave.net",
    "reference": null,
    "reference_hash": null
  }
}

币安api请求

https://api.binance.com/api/v3/ticker/price?symbol=NEARUSDT
query param:NEARUSDT

铸造nft

google api/google serverless请求

  1. 调用firebasestorage api 上传文件
https://firebasestorage.googleapis.com/v0/b/omni-live.appspot.com/o?name=arweave/9305648e-231e-42ea-b2cb-c4450be35e4a

返回内容如下

{
  "name": "arweave/9305648e-231e-42ea-b2cb-c4450be35e4a",
  "bucket": "omni-live.appspot.com",
  "generation": "1634043285387850",
  "metageneration": "1",
  "contentType": "image/jpeg",
  "timeCreated": "2021-10-12T12:54:45.408Z",
  "updated": "2021-10-12T12:54:45.408Z",
  "storageClass": "STANDARD",
  "size": "103516",
  "md5Hash": "3E27dQlO48nuDovBsMPvBw==",
  "contentEncoding": "identity",
  "contentDisposition": "inline; filename*=utf-8''9305648e-231e-42ea-b2cb-c4450be35e4a",
  "crc32c": "XEJrEg==",
  "etag": "CMr0ysz1xPMCEAE=",
  "downloadTokens": "923a3cb8-ed27-4e35-a18e-a19cb98a1688"
}
  1. 根据上一步contentDisposition中的文件名获取文件hash id
https://us-central1-omni-live.cloudfunctions.net/arweave/file/68dddb57-eeaf-48ba-8efd-ecc3dafde830

返回结果如下

{"id":"W5FxhZ3dPMfm7yRTF9QvClLCboG5ckTRaoN8HynupQc","contentType":"image/jpeg"}
  1. 元数据上链
https://us-central1-omni-live.cloudfunctions.net/arweave/metadata/

请求参数如下,请求返回tx id

{
    "category": "",
    "description": "33",
    "copies": 1,
    "media_hash": "W5FxhZ3dPMfm7yRTF9QvClLCboG5ckTRaoN8HynupQc",
    "lock": null,
    "visibility": "safe",
    "youtube_url": null,
    "animation_url": null,
    "animation_hash": null,
    "document": null,
    "document_hash": null,
    "royalty": null,
    "royalty_perc": 0.1,
    "split_revenue": null,
    "tags": [],
    "media": "https://arweave.net/W5FxhZ3dPMfm7yRTF9QvClLCboG5ckTRaoN8HynupQc",
    "extra": [],
    "title": "222",
    "store": "net.mintspace2.testnet",
    "external_url": "https://testnet.mintbase.io/store/net.mintspace2.testnet",
    "type": "NEP171"
}

the graph api请求

  1. 获取类别
    https://mintbase-testnet.hasura.app/v1/graphql
    {
    “operationName”: “Categories”,
    “variables”: {},
    “query”: “query Categories {\n thing(where: {memo: {_is_null: false}}, distinct_on: memo) {\n memo\n __typename\n }\n}\n”
    }

near rpc请求

  1. 获取区块数据
{
    "method": "block",
    "params": {
        "finality": "final"
    }
}
  1. 获取账户信息
{
    "method": "query",
    "params": [
        "account/kkst.testnet",
        ""
    ]
}
  1. 获取access key
{
    "method": "query",
    "params": [
        "access_key/kkst.testnet",
        ""
    ]
}
  1. 发送交易(同步方法)
{
    "method": "broadcast_tx_commit",
    "params": [     "DAAAAGtrc3QudGVzdG5ldACCpA75hIIUGllFDSzSuPrtaP8IKMzw7ErXP+4PvHpHq9ZJvFhoPAAAFgAAAG5ldC5taW50c3BhY2UyLnRlc3RuZXRatj72zetbE9aGVSAlMPHaDXT2hWM+0pFKa/7hbtDolAEAAAACDgAAAG5mdF9iYXRjaF9taW50pwAAAHsib3duZXJfaWQiOiJra3N0LnRlc3RuZXQiLCJtZXRhZGF0YSI6eyJyZWZlcmVuY2UiOiJnY2U2dlllNU81SWJ4LTJacG9vdXF1aC1VS2M0c1RFb0h6YUh5a1d4UGhJIiwiZXh0cmEiOm51bGx9LCJudW1fdG9fbWludCI6MSwicm95YWx0eV9hcmdzIjpudWxsLCJzcGxpdF9vd25lcnMiOm51bGx9AID0IOa1AAABAAAAAAAAAAAAAAAAAAAAAEoRlQv6r8UCekRdwTV4Ttd5FEfaYwNfIL4Nfv95Jx3A6ppYUcUz4PFABrZkPCVTOPZcMyPZDX4ehnp6ca4bsw8="
    ]
}  

调用了net.mintspace2.testnet合约的nft_batch_mint 方法, params解码后的参数如下,点击查看tx

{
  "owner_id": "kkst.testnet",
  "metadata": {
    "reference": "gce6vYe5O5Ibx-2Zpoouquh-UKc4sTEoHzaHykWxPhI",
    "extra": null
  },
  "num_to_mint": 1,
  "royalty_args": null,
  "split_owners": null
}

reference是arwaeave的tx id