0

I am attempting to deploy a smart contract on my substrate chain through 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)}
  })

However, the if statement fails and i get returned this:

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
}

I have no idea what to make of this and I'm clueless of what's wrong here. The contract can be successfully deployed through their UI (when I do this I can visual feedback that a contract on there. In this same UI I can see the amount of transaction raise by 1 everytime I run the code.

So does anyone know what information I can get out of this result or maybe what I am doing wrong? It's hard to follow the docs because it's outdated.

  • What are you using as a base node? The canvas? If so, have you looked at https://paritytech.github.io/canvas-ui/ ? – Nuke Apr 09 '21 at 16:32

1 Answers1

0

So apparently (my guess) when you deploy a contract through code, it doesn't end up in the UI. I was able to deploy and interact with the contract in code, without it ever showing up in the UI.

And the if statement ran twice as well, first time returning a failure and second time successing. So all the time I thought it failed while it just failed the first time and succeeded the second time.