【问题标题】:Trying to deploy a contract with polkadotjs but returns CodeSubmittableResult without much info尝试使用 polkadotjs 部署合约,但返回 CodeSubmittableResult 而没有太多信息
【发布时间】:2021-04-09 15:59:47
【问题描述】:

我正在尝试通过 polkadotJS 在我的底层链上部署智能合约。

const unsub = await code
  .tx.new( { gasLimit: 200000, value: 5000 }, true)
  .signAndSend(alicePair, (result) => {
    if (result.status.isInBlock || result.status.isFinalized) {
      // here we have an additional field in the result, containing the blueprint
      blueprint = result.blueprint;

      unsub();
    }else{console.log(result)}
  })

但是,if 语句失败,我得到了返回:

CodeSubmittableResult {
  dispatchError: undefined,
  dispatchInfo: undefined,
  events: [],
  status: Type {
    registry: TypeRegistry { createdAtHash: undefined },
    createdAtHash: undefined,
    isFuture: [Getter],
    asFuture: [Getter],
    isReady: [Getter],
    asReady: [Getter],
    isBroadcast: [Getter],
    asBroadcast: [Getter],
    isInBlock: [Getter],
    asInBlock: [Getter],
    isRetracted: [Getter],
    asRetracted: [Getter],
    isFinalityTimeout: [Getter],
    asFinalityTimeout: [Getter],
    isFinalized: [Getter],
    asFinalized: [Getter],
    isUsurped: [Getter],
    asUsurped: [Getter],
    isDropped: [Getter],
    asDropped: [Getter],
    isInvalid: [Getter],
    asInvalid: [Getter]
  },
  blueprint: undefined,
  contract: undefined
}

我不知道该怎么做,我也不知道这里出了什么问题。合约可以通过their UI 成功部署(当我这样做时,我可以直观地反馈那里的合约。 在同一个 UI 中,每次运行代码时,我都可以看到事务量增加 1。

那么有谁知道我可以从这个结果中得到什么信息,或者我做错了什么? 文档已经过时了,很难遵循。

【问题讨论】:

标签: substrate polkadot polkadot-js


【解决方案1】:

显然(我的猜测)当您通过代码部署合同时,它不会最终出现在 UI 中。我能够在代码中部署合约并与之交互,而不会出现在 UI 中。

if 语句也运行了两次,第一次返回失败,第二次成功。所以我一直认为它失败了,它只是第一次失败,第二次成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    相关资源
    最近更新 更多