Skip to main content

This is because of Shibuya has updated to Weights v2.

If you are getting this error on polkadot.js we are working on a fix for it https://github.com/polkadot-js/apps/pull/8538.

If you are getting this from your code you can fix like this:

Weights v2 requires refTime and proofSize. refTime is equal to v1 weight.

Both values can be fetched by sending the txn as a query and using the gasRequired value.

const { gasRequired, result, output } = await contract.query.flip(
  address,
  {
    gasLimit: api.registry.createType('WeightV2', {
      refTime,
      proofSize,
    }) as WeightV2,
    storageDepositLimit,
  }
)

const gasLimit = api.registry.createType('WeightV2', gasRequired) as WeightV2

// Send the transaction, like elsewhere this is a normal extrinsic
// with the same rules as applied in the API (As with the read example,
// additional params, if required can follow)
await contract.tx
  .flip({
    gasLimit: gasLimit,
    storageDepositLimit
  })
  .signAndSend(account, async (res) => {
    if (res.status.isInBlock) {
      console.log('in a block')
    } else if (res.status.isFinalized) {
      console.log('finalized')
    }
  })
const { gasRequired, result, output } = await contract.query.flip(
  address,
  {
    gasLimit: api.registry.createType('WeightV2', {
      refTime,
      proofSize,
    }) as WeightV2,
    storageDepositLimit,
  }
)

const gasLimit = api.registry.createType('WeightV2', gasRequired) as WeightV2

// Send the transaction, like elsewhere this is a normal extrinsic
// with the same rules as applied in the API (As with the read example,
// additional params, if required can follow)
await contract.tx
  .flip({
    gasLimit: gasLimit,
    storageDepositLimit
  })
  .signAndSend(account, async (res) => {
    if (res.status.isInBlock) {
      console.log('in a block')
    } else if (res.status.isFinalized) {
      console.log('finalized')
    }
  })

This is because of Shibuya has updated to Weights v2.

If you are getting this error on polkadot.js we are working on a fix for it https://github.com/polkadot-js/apps/pull/8538.

If you are getting this from your code you can fix like this:

Weights v2 requires refTime and proofSize. refTime is equal to v1 weight.

Both values can be fetched by sending the txn as a query and using the gasRequired value.

const { gasRequired, result, output } = await contract.query.flip(
  address,
  {
    gasLimit: api.registry.createType('WeightV2', {
      refTime,
      proofSize,
    }) as WeightV2,
    storageDepositLimit,
  }
)

const gasLimit = api.registry.createType('WeightV2', gasRequired) as WeightV2

// Send the transaction, like elsewhere this is a normal extrinsic
// with the same rules as applied in the API (As with the read example,
// additional params, if required can follow)
await contract.tx
  .flip({
    gasLimit: gasLimit,
    storageDepositLimit
  })
  .signAndSend(account, async (res) => {
    if (res.status.isInBlock) {
      console.log('in a block')
    } else if (res.status.isFinalized) {
      console.log('finalized')
    }
  })

This is because of Shibuya has updated to Weights v2.

If you are getting this error on polkadot.js we are working on a fix for it https://github.com/polkadot-js/apps/pull/8538.

If you are getting this from your code you can fix like this:

Weights v2 requires refTime and proofSize. refTime is equal to v1 weight.

Both values can be fetched by sending the txn as a query and using the gasRequired value.

const { gasRequired, result, output } = await contract.query.flip(
  address,
  {
    gasLimit: api.registry.createType('WeightV2', {
      refTime,
      proofSize,
    }) as WeightV2,
    storageDepositLimit,
  }
)

const gasLimit = api.registry.createType('WeightV2', gasRequired) as WeightV2

// Send the transaction, like elsewhere this is a normal extrinsic
// with the same rules as applied in the API (As with the read example,
// additional params, if required can follow)
await contract.tx
  .flip({
    gasLimit: gasLimit,
    storageDepositLimit
  })
  .signAndSend(account, async (res) => {
    if (res.status.isInBlock) {
      console.log('in a block')
    } else if (res.status.isFinalized) {
      console.log('finalized')
    }
  })
Source Link

This is because of Shibuya has updated to Weights v2.

If you are getting this error on polkadot.js we are working on a fix for it https://github.com/polkadot-js/apps/pull/8538.

If you are getting this from your code you can fix like this:

Weights v2 requires refTime and proofSize. refTime is equal to v1 weight.

Both values can be fetched by sending the txn as a query and using the gasRequired value.

const { gasRequired, result, output } = await contract.query.flip(
  address,
  {
    gasLimit: api.registry.createType('WeightV2', {
      refTime,
      proofSize,
    }) as WeightV2,
    storageDepositLimit,
  }
)

const gasLimit = api.registry.createType('WeightV2', gasRequired) as WeightV2

// Send the transaction, like elsewhere this is a normal extrinsic
// with the same rules as applied in the API (As with the read example,
// additional params, if required can follow)
await contract.tx
  .flip({
    gasLimit: gasLimit,
    storageDepositLimit
  })
  .signAndSend(account, async (res) => {
    if (res.status.isInBlock) {
      console.log('in a block')
    } else if (res.status.isFinalized) {
      console.log('finalized')
    }
  })