Developer Hub
Relation ProtocolRelation ONE APIRelation Graph API
中文
中文
  • 概述
  • 快速开始
    • 基于Relation Protocol 部署合约
    • 使用Graph Indexer部署Social Graph的查询服务
  • 关键概念
    • RDF
    • Semantic SBTs
    • Social Graph
  • Relation Protocol的架构
  • Schema Standard
    • 概述
    • schema如何约束智能合约
    • schema存储
    • schema列表
  • Contract Open Standard
    • 概述
    • Identity
      • Name Service
    • Relationship
      • Follow
      • Dao
    • Publication
      • Content
      • Privacy Content
  • Open Standard API
    • 介绍
    • EIP-6239
    • 业务接口
      • Identity
      • Relationship
      • Publication
  • Graph Indexer
    • 定义与用途
    • 事件监听
    • 解析数据
    • 构建图谱
  • 集成
    • 快速开始
    • 构建Relation Protocol社交图谱
    • Relation Protocol 资源列表
    • NameService 合约请求示例
    • Follow 合约请求示例
    • Dao 合约请求示例
    • Content 合约请求示例
    • PrivacyContent 合约请求示例
  • Relation Name Service
    • Name Service Api
  • 用例
  • 附录
    • 使用Hardhat部署合约
    • SemanticSBT部署工具
Powered by GitBook
On this page
  1. 快速开始

基于Relation Protocol 部署合约

Last updated 1 year ago

我们可以使用Relation 提供的,快速部署属于自己的Semantic SBT合约。

使用的部署工具为Hardhat,关于Hardhat的使用可参考:

  1. 下载合约

git clone git@github.com:relationlabs/semanticSBT.git
  1. 安装依赖

cd semanticSBT
npm install
  1. 修改配置文件

vi hardhat.config.js

注释以下内容(我们使用本地网络演示合约部署,不需要配置其他网络)

rinkeby: {
  url: `https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}`,
  accounts: [`${PRIVATE_KEY}`]
}
  1. 编译

npx hardhat node &
npx hardhat compile
  1. 修改合约初始化参数

打开部署脚本

vi scripts/template/deployFollow.js

修改参数

const name = "Bob's Connection Template";
const symbol = 'SBT';
const baseURI = 'https://api.example.com/v1/';
  • name: 合约名称

  • symbol: 合约symbol

  • baseURI: 合约tokenURI的根目录

  1. 执行部署脚本

npx hardhat run scripts/template/deployFollow.js

部署成功后,您将再控制台看到类似信息:

SemanticSBTLogic deployed ,contract address: 0x84323b27A2Ee0DecFe417695F5718BdeC23320E5
Follow deployed ,contract address: 0x89235270C230F8A9d16D49D18fC38cf9343B5F9A
Follow initialize successfully!
0xc1155B6aE7031fE0B9365Bec744aa8E8a298c78b following 0x7ed9cdb704052a9ba93e9df3f604436655680f86 successfully!
The rdf of the first token is: 
            :Soul_0xc1155b6ae7031fe0b9365bec744aa8e8a298c78b p:following :Soul_0x7ed9cdb704052a9ba93e9df3f604436655680f86.

其中,最后一句输出内容为一条RDF数据,表示了两个地址之间的following关系:

:Soul_0xc1155b6ae7031fe0b9365bec744aa8e8a298c78b p:following :Soul_0x7ed9cdb704052a9ba93e9df3f604436655680f86.
合约模版
使用Hardhat部署合约