📝数据处理-action序列化

action序列化

  const client = await getClient();
  const contract = await client.contract("testmulsign1");
  const data = {
    issuer: "testmulsign1",
    wallet_id: "0",
    mulsigner: "solo11111111",
    weight: 1,
  };
  // 102673386a99b1ca000000000000000010420821844023c501000000
  const hex = contract.fc
    .toBuffer(
      "setmulsigner", // 合约方法
      data,
    )
    .toString("hex");

action反序列化

  const client = await getClient();
  const contract = await client.contract("testmulsign1");
  // {issuer: "testmulsign1", wallet_id: "0", mulsigner: "solo11111111", weight: 1}
  const data = contract.fc.fromBuffer(
    "setmulsigner", // 合约方法
    Buffer.from(
      // 方法对应的系列化字符串
      "102673386a99b1ca000000000000000010420821844023c501000000",
      "hex",
    ),
  );

首先要知道哪个合约,然后要知道哪个actiion(即调用的合约方法)。这样就能具化到对应参数,然后就可以根据序列化出来的HEX(102673386a99b1ca000000000000000010420821844023c501000000)进行反序列化。

最后更新于