Send an transaction to deploy contract by predicate

Hello, in the last few days I have been trying to carry out a transaction that deploys a contract written in sway, using a predicate.
This predicate checks the transaction’s subscribers (multsig).

For more details check the code
On folder packages/sway

I have been having problems checking these signatures within the predicate, as an error is returned to me, stating:

ClientError: PredicateVerificationFailed(PanicInstruction(PanicInstruction { reason: ContractInstructionNotAllowed, instruction: RVRT { value: 0x0 } (bytes: 36 00 00 00) })): {“response”:{“data”:null,“errors”:[{“message”:“PredicateVerificationFailed(PanicInstruction(PanicInstruction { reason: ContractInstructionNotAllowed, instruction: RVRT { value: 0x0 } (bytes: 36 00 00 00) }))”,“locations”:[{“line”:2,“column”:3}],“path”:[“submit”]}],“status”:200,“headers”:{}},“request”:{“query”:“mutation submit($encodedTransaction: HexString!) {\n submit(tx: $encodedTransaction) {\n id\n }\n}”

These are the details of the tx that is about to be sent:

Summary
{
      type: 1,
      policyTypes: 9,
      inputs: [
        {
          type: 0,
          txID: '0x793438ce4a3238001179f36658a73e07a8a2310a8a1b71498fc37855a98d2d1b',
          outputIndex: 0,
          owner: '0xb352367bdc8f8d93b557fcd5ccb959ace0be6d125afad8129c0b71c91a2565ad',
          amount: <BN: 0x5f5e100>,
          assetId: '0x0000000000000000000000000000000000000000000000000000000000000000',
          txPointer: [Object],
          witnessIndex: 2,
          maturity: 0,
          predicateGasUsed: <BN: 0x0>,
          predicateLength: 6016,
          predicateDataLength: 0,
          predicate: <hex/>
          predicateData: '0x'
        }
      ],
      outputs: [
        {
          type: 4,
          contractId: '0x7d430de56abdcfe77e8cc84f79a58bb31e59ed36f0c31953daefbe5c212b622a',
          stateRoot: '0x0000000000000000000000000000000000000000000000000000000000000000'
        },
        {
          type: 2,
          to: '0xb352367bdc8f8d93b557fcd5ccb959ace0be6d125afad8129c0b71c91a2565ad',
          amount: <BN: 0x0>,
          assetId: '0x0000000000000000000000000000000000000000000000000000000000000000'
        }
      ],
      policies: [ { data: <BN: 0x1>, type: 1 }, { data: <BN: 0x2710>, type: 8 } ],
      witnesses: [
        {
          data: '0x740000034700000000000000000008cc5dfcc00110fff3005d4060495d47f00913490440764800085d47f00a13490440764800745d47f00b134904407648013b72f0007b36f000001aec5000910002185d43f00c104103005d47f00c104513007248002028ed04805fec0004504bb028724c0020284914c05d4fb0045d47f0041b4534405d4bf004104514805d4bf005104514805d4bf0061f4514805d4bf00719493480504fb09872500020284d05005043b1f872500020284135005043b1f8504fb1f85053b0e81ae910001ae5400020f8330058fbe00250fbe004740001dd1a47d0005053b1081ae810001ae5400020f8330058fbe00250fbe004740001d51a53d0005057b13872580020285515805047b1b872580020284545805053b178a35154615047b1587250002028453500504fb1785053b198a35114e072440020284144405043b0b872440020284144405047b048724c0020284504c05fec100d5fed200e5043b0485047b1d872480020284504805d43b00d5d47b00e5d4bf0081b4904805d4ff0041b493480264800001a487000504fb1d8394904d0764000065043b0885fec0011504bb12872440010284904407400000a5043b0785fec100f5d4ff0041b453440104524405d4510005fed1010504bb12872440010284904405043b0d872440010284124405d43b0251341004076400001360000005d43b01c244000001aec5000910003f05d43f00c104103005d47f00c104513005d53f00c105143005d4bf00c10492300724c002028ed04c05fec00045043b028724c0020284114c05043b0a872440020284144405fec00195041002872440020284124405d43b0195d47f0041b4504405d4bf004104514805d4bf005104514805d4bf0061f4514805d4bf00719410480504bb110724c0020284944c0504fb39072500020284d2500504bb390504fb3905053b1a01ae910001ae5400020f8330058fbe00250fbe004740001631a47d0005053b1c01ae810001ae5400020f8330058fbe00250fbe0047400015b1a53d0005057b23072580020285515805047b33072580020284545805053b2b0a35154615047b2507250002028453500504fb2b05053b2d0a35114e072440020284944405047b1307248002028454480504bb048724c0020284914c05fec100d5fed000e5043b0485047b37072480020284504805d43b00d5d47b00e5d4bf0081b4904805d4ff0041b493480264800001a487000504fb370394904d0764000065043b1005fec0020504bb22072440010284904407400000a5043b0f05fec101e5d4ff0041b453440104524405d4510005fed101f504bb22072440010284904405043b19072440010284124405d43b0441341004076400001360000005d43b033205d00405d43b0045d47f0041b4504405d4bf004104514805d4bf005104514805d4bf0061f4514805d4bf00719410480504bb150724c0020284bb4c0504fb3b072500020284d2500504bb3b0504fb3b05053b1e01ae910001ae5400020f8330058fbe00250fbe004740001001a47d0005053b2001ae810001ae5400020f8330058fbe00250fbe004740000f81a53d0005057b27072580020285515805047b35072580020284545805053b2f0a35154615047b2907250002028453500504fb2f05053b310a35114e072440020284944405047b1707248002028454480504bb078724c0020284914c05fec10135fed00145043b0785047b3d072480020284504805d43b0135d47b0145d4bf0081b4904805d4ff0041b493480264800001a487000504fb3d0394934d05d4ff0041b453440104524405f4570005047b3d03b450490240000001aec5000910003f05d43f00c104103005d47f00c104513005d4bf00c104923005d4ff00c104d33007250002028ed05005fec00045043b02872500020284115005043b0a872440020284124405fec00195041002872440020284134405d43b0195d47f0041b4504405d4ff004104514c05d4ff005104514c05d4ff0061f4514c05d4ff007194104c0504fb11072500020284d2500504bb3907250002028493500504bb390504fb3905053b1a01ae910001ae5400020f8330058fbe00250fbe004740000991a47d0005053b1c01ae810001ae5400020f8330058fbe00250fbe004740000911a53d0005057b23072580020285515805047b33072580020284545805053b2b0a35154615047b2507250002028453500504fb2b05053b2d0a35114e072440020284944405047b1307248002028454480504bb048724c0020284914c05fec100d5fed000e5043b0485047b37072480020284504805d43b00d5d47b00e5d4bf0081b4904805d4ff0041b493480264800001a487000504fb370394904d0764000065043b1005fec0020504bb22072440010284904407400000a5043b0f05fec101e5d4ff0041b453440104524405d4510005fed101f504bb22072440010284904405043b19072440010284124405d43b0441341004076400001360000005d43b033105d00405d43b0045d47f0041b4504405d4bf004104514805d4bf005104514805d4bf0061f4514805d4bf00719410480504bb150724c0020284bb4c0504fb3b072500020284d2500504bb3b0504fb3b05053b1e01ae910001ae5400020f8330058fbe00250fbe004740000361a47d0005053b2001ae810001ae5400020f8330058fbe00250fbe0047400002e1a53d0005057b27072580020285515805047b35072580020284545805053b2f0a35154615047b2907250002028453500504fb2f05053b310a35114e072440020284944405047b1707248002028454480504bb078724c0020284914c05fec10135fed00145043b0785047b3d072480020284504805d43b0135d47b0145d4bf0081b4904805d4ff0041b493480264800001a487000504fb3d0394934d05d4ff0041b453440104524405f4570005047b3d03b450490240000001af05000910000285ff100005ff110015ff120025ff130035ff3b0041aec5000910000201a43a0001a4790001a4be0005fec00005fec00015fec00025fed00031a43b000724c0020284504c01af51000920000201af9200059f050285d43c0005d47c0015d4bc0025d4fc0035defc004920000284af80000f383b0ce51358be57daa3b725fe44acdb2d880604e367199080b4379c41bb6ed0000000000000008000000000000001f000000000000000500000000000000040000000000000020000000003c5bb3f200000000ea57470f000000005842f1be00000000000008cc',
          dataLength: 2356
        },
        {
          data: '0x64e651b10a50d8180297f13b56173458f8a068c1a91996abc0aa3676e5e3d6b847bbe67afe0dec822a51a5ec1aaefb436db714aaa7842b76236d3a54e912839a',
          dataLength: 64
        },
        {
          data: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
          dataLength: 64
        }
      ],
      inputsCount: 1,
      outputsCount: 2,
      witnessesCount: 3,
      bytecodeLength: 589,
      bytecodeWitnessIndex: 0,
      storageSlotsCount: 0,
      salt: '0xa76e883187520f1c320989a74d0a4f6e98afb452d21f105b8a5b0001a7e561c7',
      storageSlots: []
    }

The revert() function is not allowed within predicates. Reverts emit logs, which is stateful and not allowed within predicates.

You can use assert() or just return false instead.

1 Like

OK, thanks for answering my question.
But that’s not my problem yet…

If you look at the code link, I’m using the same predicate to send different types of tx:

  • sending assets → script type is working
  • contract deploy → create type returns this error.

You cannot use contract “opcodes” in predicates… from a cursory read, I have not found anything suspicious at first… any idea if you are using any of these?
image.

A suggestion here would be to comment the predicate code until you find the “culprit line”.

We have one issue here, to improve these checks inside the compiler

i dont know…
probabli the transactions with create type have on of items
because this formatt normaly used to send just of wallet

on predicate i think no, because send transactions with script type are work

i will debbug more, thanks :slight_smile:

1 Like

Yup, pls lmk if you still have issues with that. Happy to help :slight_smile:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.