PRESS.one 开发者社区

PRESS.one 开发者社区

  • 文档
  • 博客
  • 开发者论坛

›指南

指南

  • 简介
  • DApp 开发流程
  • 创建 DApp
  • 数字签名相关知识
  • PRS 协议

REST API 文档

  • 概述
  • API 鉴权
  • 用户授权
  • 获取数字签名
  • 签名文件相关
  • 合约相关
  • 钱包相关

Node.js SDK 文档

  • SDK 安装
  • 用户授权
  • 签名文件相关
  • 合约相关
  • 钱包相关

PRS 协议

开发者通过 SDK 和节点交互,不需要从头实现 PRS 协议,SDK 隐藏了底层区块链操作的复杂性。如果开发者直接调用 PRS REST API 和节点进行交互,则需要传递指定的块结构才可以通过验证,数据才能被打包上链。

PRS 支持多种类型的数据上链,包括:

  1. 文件签名
  2. 身份绑定
  3. Mixin 绑定
  4. DApp 授权
  5. 合约
  6. 合约绑定
  7. 合约请款
  8. 合约付款

文件签名

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'PUBLISH:2',
  meta         : {
      uris  : [ 'p1s://6a/2e/6a2e87a57b8cc268ff2bc28b32b225b08651ceb2c4ac37408bd4e6562337684a.md' ],
      mime : 'text/markdown;charset=UTF-8',
  },
  data         : {
      file_hash : '6a2e87a57b8cc268ff2bc28b32b225b08651ceb2c4ac37408bd4e6562337684a',
  },
  hash         : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature    : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,文件签名类型为 'PUBLISH:2'。
  • meta:
    • uris: 文件存储地址。
    • mime: 文件类型。
  • data:
    • file_hash: 文件内容的 hash 值。
  • hash: 整个 data 的 hash 值
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

身份绑定

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'IDENTITY:2',
  meta         : {
      proof_url : 'https://twitter.com/ElvisZPZP/status/1543306685946',
  },
  data         : {
      profile_provider : 'twitter.com',
      profile_url      : 'https://xxxx.com/x/134',
  },
  hash      : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,身份绑定类型为 'IDENTITY:2'。
  • meta:
    • proof_url: 身份证明的链接。
  • data:
    • profile_provider: 绑定身份的平台类型。
    • profile_url: 绑定身份的个人主页。
  • hash: 整个 data 的 hash 值
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

Mixin 绑定信息

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'IDENTITY:2',
  meta         : {},
  data         : {
      profile_provider : 'mixin.one',
      profile_url      : 'mixin://transfer/c39c2ecc-2109-499f-b6c4-d6f278ea29fb',
  },
  hash      : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,Mixin 绑定信息类型为 'IDENTITY:2'。
  • meta:
  • data:
    • profile_provider: Mixin 绑定信息固定为 'mixin.one'。
    • profile_url: mixin 提供的转账链接。
  • hash: 整个 data 的 hash 值
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

DAPP 授权

  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'AUTHORIZATION:2',
  meta         : {},
  data         : {
      app_provider : 'http://press.one',
      app_address  : 'c609224f9590e60fae1723ad4d612c2db1a41595',
      auth_address : 'c7b5603bdf7a027f9d485888f1f55565e71ed4fb',
      authorized   : true, // false,
  },
  hash      : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,DApp 授权类型为 'AUTHORIZATION:2'。
  • meta:
  • data:
    • app_provider:
    • app_address: 授权 DApp 的 appAddress,开发者创建 DApp 之后可获取到。
    • auth_address: 新生成的密钥对的 address,授权成功该密钥对即可进行签名等操作,吊销授权即失去签名的权限。
    • authorized: true: 授权, false: 吊销授权。
  • hash: 整个 data 的 hash 值.
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

合约

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'PUBLISH:2',
  meta         : {
      uri  : 'data:text/plain;charset=UTF-8,%E6%B5%8B%E8%AF%95',
      mime : 'text/prsc;charset=UTF-8',
  },
  data         : {
      file_hash : '6a2e87a57b8cc268ff2bc28b32b225b08651ceb2c4ac37408bd4e6562337684a',
  },
  hash         : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature    : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,合约类型为 'PUBLISH:2'。
  • meta:
    • uri: 合约文件 url。
    • mime: 文件类型。
  • data:
    • file_hash: 合约源码的 hash 值。
  • hash: 整个 data 的 hash 值.
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

合约绑定

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'WRAPPING:2',
  meta         : {},
  data         : {
      beneficiary_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      content_id          : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      contract_id         : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
  },
  hash         : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature    : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,合约绑定类型固定为 'WRAPPING:2'。
  • meta:
  • data:
    • beneficiary_address: 收款人 address。
    • content_id: 文件的 区块 id。
    • contract_id: 合约的 区块 id。
  • hash: 整个 data 的 hash 值.
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

合约请款

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'BILL:2',
  meta         : {
      beneficiary_address   : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      beneficiary_wallet_id : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      content_id            : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      contract_id           : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      contract_license      : 'usage2',
      amount                : '0.002',
      currency              : 'CNB',
  },
  data         : {
      wrapping_id      : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      payment_provider : 'mixin.one',
      payment_trace_id : '80272f8e-d06c-46fd-a427-f51274332927',
  },
  hash         : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature    : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,合约请款类型固定为 'BILL:2'。
  • meta:
    • beneficiary_address: 收款人 address。
    • beneficiary_wallet_id: 收款人的钱包 id。
    • content_id: 文件的 区块 id。
    • contract_id: 合约的 区块 id。
    • contract_license: 需要购买合约的类型。
    • amount: 价格。
    • currency: 币种。
  • data:
    • wrapping_id: 。
    • payment_provider: 支付平台。
    • payment_trace_id: 支付平台返回的订单号,用于之后的对账。
  • hash: 整个 data 的 hash 值.
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。

合约付款

{
  id           : '3f6c5cc0b45135d98d46b954a5c84e2cbd03f3f86b92a9cb3012007a4185befe',
  user_address : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
  type         : 'RECEIPT:2',
  meta         : {
      beneficiary_address   : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      beneficiary_wallet_id : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      payer_address         : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      payer_wallet_id       : 'ee6ddad145f681fd5bd19eca003c9d204d214471',
      content_id            : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      contract_id           : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      contract_license      : 'usage2',
      amount                : '0.002',
      currency              : 'CNB',
  },
  data         : {
      bill_id             : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
      payment_snapshot_id : '1b8fe06b8802e125ec6b2847cba1d9a350a34008328790cb5c70788e6e2abc54',
  },
  hash         : '8dc1ca77aa183004086df871c8e3b8c972aa065155976b1ce9609a37a35ea667',
  signature    : 'b50009fe7d51025c86b89967f8718adfa48aebc9fd26cdb7120e32f2001a24d7',
}
  • id: 区块 id。
  • user_address: 用户的 address。
  • type: 区块类型,合约请款类型固定为 'BILL:2'。
  • meta:
    • beneficiary_address: 收款人 address。
    • beneficiary_wallet_id: 收款人的钱包 id。
    • content_id: 文件的 区块 id。
    • contract_id: 合约的 区块 id。
    • contract_license: 需要购买合约的类型。
    • amount: 价格。
    • currency: 币种。
  • data:
    • bill_id: 请款单的 id。
    • payment_snapshot_id: 支付凭证 id。
  • hash: 整个 data 的 hash 值.
  • signature: user_address 对应的用户使用其私钥对 data 的 hash 进行签名。
← 数字签名相关知识概述 →
  • 文件签名
  • 身份绑定
  • Mixin 绑定信息
  • DAPP 授权
  • 合约
  • 合约绑定
  • 合约请款
  • 合约付款
文档
介绍基础知识创建 DApp创建合约
社区
TwitterMedium微信公众号开发者论坛
更多
官方博客GitHub
Copyright © 2023 PRESSone