@acryl/marshall 中文文档教程

发布于 5年前 浏览 18 项目主页 更新于 3年前

@acryl/marshall

Marshall 可以序列化和解析 Acryl 区块链数据结构

Includes:

  • Serialization primitives
  • Parsing primitives
  • Binary to js converters
  • Js to binary converters
  • JSON to js converters
  • Js to JSON converters

Usage:

import { binary, json } from '@acryl/marshall'

const tx = {
  type: 10,
  version: 2,
  fee: 100000,
  senderPublicKey: '7GGPvAPV3Gmxo4eswmBRLb6bXXEhAovPinfcwVkA2LJh',
  timestamp: 1542539421565,
  id: '1bVuFdMbDAk6dhcQFfJFxpDjmm8DdFnnKesQ3wpxj7P',
  proofs:
    ['5cW1Ej6wFRK1XpMm3daCWjiSXaKGYfL7bmspZjzATXrNYjRVxZJQVJsDU7ZVcxNXcKJ39fhjxv3rSu4ovPT3Fau8'],
  alias: 'MyTestAlias'
};

// Binary converter
const bytes = binary.serializeTx(tx);

const txb = binary.parseTx(bytes)

// json converted
const jsonString = json.stringifyTx(tx)

const txj = json.parseTx(jsonString)

@acryl/marshall

Marshall can serialize and parse Acryl blockchain data structures

Includes:

  • Serialization primitives
  • Parsing primitives
  • Binary to js converters
  • Js to binary converters
  • JSON to js converters
  • Js to JSON converters

Usage:

import { binary, json } from '@acryl/marshall'

const tx = {
  type: 10,
  version: 2,
  fee: 100000,
  senderPublicKey: '7GGPvAPV3Gmxo4eswmBRLb6bXXEhAovPinfcwVkA2LJh',
  timestamp: 1542539421565,
  id: '1bVuFdMbDAk6dhcQFfJFxpDjmm8DdFnnKesQ3wpxj7P',
  proofs:
    ['5cW1Ej6wFRK1XpMm3daCWjiSXaKGYfL7bmspZjzATXrNYjRVxZJQVJsDU7ZVcxNXcKJ39fhjxv3rSu4ovPT3Fau8'],
  alias: 'MyTestAlias'
};

// Binary converter
const bytes = binary.serializeTx(tx);

const txb = binary.parseTx(bytes)

// json converted
const jsonString = json.stringifyTx(tx)

const txj = json.parseTx(jsonString)
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文