您当前的位置: 首页 >  区块链

每日出拳老爷子

暂无认证

  • 3浏览

    0关注

    135博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

区块链-Reach:如何在Reach和前端JS中埋Log

每日出拳老爷子 发布时间:2021-09-09 09:38:34 ,浏览量:3

背景

区块链程序调式时希望把握运行状况,知道运行过程中每一步变量的变化。

办法

下面两个例子,分别表明了如何在后端RSH文件和前端JS文件中买入Log输出语句的方法

RSH
'reach 0.1';
'use strict';

export const main = Reach.App(() => {
  const A = Participant('Alice', {
    ...hasConsoleLogger,
  });
  deploy();

  A.interact.log(true);
  A.interact.log(1);
  A.interact.log([1, true]);
  A.interact.log({x: 1, y: true});
  A.interact.log(Maybe(UInt).Some(5));

  exit();
});
JS(mjs)
import { loadStdlib } from '@reach-sh/stdlib';
import * as backend from './build/index.main.mjs';

(async () => {
  const stdlib = await loadStdlib();
  const startingBalance = stdlib.parseCurrency(10);

  const accAlice = await stdlib.newTestAccount(startingBalance);
  const ctcAlice = accAlice.deploy(backend);

  await Promise.all([
    backend.Alice(
      ctcAlice,
      { ...stdlib.hasConsoleLogger },
    ),
  ]);
})();
关注
打赏
1657016083
查看更多评论
立即登录/注册

微信扫码登录

0.5723s