Skip to content

BioforestChain/BFMeta-Transaction-Maker

Repository files navigation

BFMeta-Transaction-Maker

Installation - 安装

$ npm install @bfmeta/transaction-maker-api

Requrements - 必要条件

  • npm

  • typescript

Usage - 用法

Server

// 运行目录下建 config/config.json 填入以下内容
{
    "//port": "事件服务器监听的端口号",
    port: 8888,
    "//loggerConfig": "日志配置",
    loggerConfig: {
        "//level": "日志等级,info warn debug error,默认 error",
        level: "debug",
        "//limit": "单文件日志大小 mb",
        limit: 100,
        "//backup": "日志保留份数",
        backup: 100,
        "//dateExpire": "根据时间切割",
        dateExpire: false,
        "//daysToRotate": "日志滚动时间 天",
        daysToRotate: 30
    },
    "//chainNodeIps": "可用的链节点 ip",
    chainNodeIps: ["127.0.0.1"],
    "//broadcastTimeout": "广播超时时间,默认 30000",
    broadcastTimeout: 30000,
    "//genesisInfoConfig": "创世块信息",
    genesisInfoConfig: {
        "//genesisBlockPath": "创世块路径",
        genesisBlockPath: "genesisInfos/bfmtest-genesisBlock-testnet.json",
        "//genesisBlockLicensePath": "创世块授权文件路径",
        genesisBlockLicensePath: "genesisInfos/bfmtest-license-testnet.json"
    },
    "//lang": "密钥类型 cn 汉语、jp 日语、sp 西班牙语、it 意大利语、fr 法语、en 英语",
    lang: "en"
}
// 运行 transaction-marker-server 服务

Client

import { BFMetaTrMaker } from "@bfmeta/transaction-maker-api";
import { PARENT_ASSET_TYPE } from "@bfmeta/transaction-maker-core";

const config: TransactionMaker.Api.ConfigOptions = {
    "//ips": "事件服务器的 ip,端口",
    ips: ["127.0.0.1:8888"],
    "//requestTimeout": "请求超时时间,默认 10000",
    requestTimeout: 10000,
};

const bfmetaTrMaker = new BFMetaTrMaker(config);

// 生成事件然后广播
const result = await bfmetaTrMaker.transaction.generateTransferAny(argv, ipInfo.ip);

if (result.success) {
    const resp = await bfmetaTrMaker.transaction.broadcastTransaction({
        transaction: result.result,
        ip: ipInfo.nodeIp,
    });
    if (resp.success) {
        console.log(resp.result);
    } else {
        console.log(resp);
    }
} else {
    console.log(result);
}

// 或者

// 生成事件并且广播

const result = await bfmetaTrMaker.transaction.sendTransferAny(argv, ipInfo);
console.log(result);

Changelog - 更新日志

  • 1.0.8
    • 更新文档,发布 1.0.8server 程序