1

I am trying to construct the storage needed to do an on chain contract call but I'm having trouble passing in the parameters. What is making it tricky is that one of the parameters is of type TContract, and next four parameters after that are associated with it.

Specifically, the parameters that corresponds to the types:

             (pair (contract %k
                      (pair (pair (mutez %newCustBal) (mutez %newMerchBal))
                            (pair (bytes %newRevLock) (bool %valid))))

are supposed to be:

              (Pair "KT1DskKf2HwDqoiL45PWZ7d72pn2jhfNxoos%receiveCall"
                    (Pair (Pair 1000000 29000000)
                          (Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))

But it seems to be affecting the pairing of the whole storage? Below is part of the output which contains the error including the whole storage parameter. In this pastebin link is the whole output from running the whole test, including the contract origination.

https://pastebin.com/vnK5pMMe

Invalid argument passed to contract KT1XLndPcmBKtsYcFtguZtstxeQKdLm2uxwy.
At (unshown) location 0, value
  (Pair (Pair (Pair "randomchanid" (Pair 1000000 "dummy_g2"))
              (Pair "KT1DskKf2HwDqoiL45PWZ7d72pn2jhfNxoos%receiveCall"
                    (Pair (Pair 1000000 29000000)
                          (Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
              (Pair 29000000 "dummy_merchPk0"))
        (Pair (Pair "dummy_merchPk1" (Pair "dummy_merchPk2" "dummy_merchPk3"))
              (Pair (Pair "dummy_merchPk4"
                          0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c)
                    (Pair "dummy_s1" "dummy_s2"))))
is invalid for type
  pair (pair (pair (string %chanID) (pair (mutez %custBal) (string %g2)))
             (pair (contract %k
                      (pair (pair (mutez %newCustBal) (mutez %newMerchBal))
                            (pair (bytes %newRevLock) (bool %valid))))
                   (pair (mutez %merchBal) (string %merchPk0))))
       (pair (pair (string %merchPk1) (pair (string %merchPk2) (string %merchPk3)))
             (pair (pair (string %merchPk4) (bytes %revLock)) (pair (string %s1) (string %s2)))).
At (unshown) location 1, primitive Pair expects 2 arguments but is given 3.
Fatal error:
  transfer simulation failed

The issue with the above is that the second pair has three arguments (thanks FFF). However, if I fix this by putting it in another pair, I get a different error.

Invalid argument passed to contract KT1WHn9DZcF6Hg5k9LbzzUn8fe6KxELMs7vJ.
At (unshown) location 0, value
  (Pair (Pair (Pair "randomchanid" (Pair 1000000 "dummy_g2"))
              (Pair (Pair "KT1NcVoQseKE3ACPFEQCX19oVBh5ydEVdPaB%receiveCall"
                          (Pair (Pair 1000000 29000000)
                                (Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
                    (Pair 29000000 "dummy_merchPk0")))
        (Pair (Pair "dummy_merchPk1" (Pair "dummy_merchPk2" "dummy_merchPk3"))
              (Pair (Pair "dummy_merchPk4"
                          0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c)
                    (Pair "dummy_s1" "dummy_s2"))))
is invalid for type
  pair (pair (pair (string %chanID) (pair (mutez %custBal) (string %g2)))
             (pair (contract %k
                      (pair (pair (mutez %newCustBal) (mutez %newMerchBal))
                            (pair (bytes %newRevLock) (bool %valid))))
                   (pair (mutez %merchBal) (string %merchPk0))))
       (pair (pair (string %merchPk1) (pair (string %merchPk2) (string %merchPk3)))
             (pair (pair (string %merchPk4) (bytes %revLock)) (pair (string %s1) (string %s2)))).
At (unshown) location 7, value
  (Pair (Pair "KT1NcVoQseKE3ACPFEQCX19oVBh5ydEVdPaB%receiveCall"
              (Pair (Pair 1000000 29000000)
                    (Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
        (Pair 29000000 "dummy_merchPk0"))
is invalid for type
  pair (contract %k
          (pair (pair (mutez %newCustBal) (mutez %newMerchBal))
                (pair (bytes %newRevLock) (bool %valid))))
       (pair (mutez %merchBal) (string %merchPk0)).
At (unshown) location 8, value
  (Pair "KT1NcVoQseKE3ACPFEQCX19oVBh5ydEVdPaB%receiveCall"
        (Pair (Pair 1000000 29000000)
              (Pair 0x5d33df275854dc7aea1323eab177a195935d0af0cb7fa727c5b491d41244d42c False)))
is invalid for type
  contract
    (pair (pair (mutez %newCustBal) (mutez %newMerchBal))
          (pair (bytes %newRevLock) (bool %valid))).
At (unshown) location 8, unexpected primitive, only a string or a byte
sequence can be used here.
Fatal error:
  transfer simulation failed

The issue seems to be with the types associated with the output of the contract call.

  • 1
    The second Pair has three arguments. – FFF Oct 14 at 2:01
  • Okay I see that more clearly now. But the issue is that the types associated with the contract call are not getting interpreted on the right level. It seems like they should be one level below the contract. I'm talking specifically about the line directly under "(pair (contract %k" . In the types, the next pair comes underneath, whereas when I try to enter it, it's on the same level as the contract. Does that make sense? – Darius Oct 14 at 11:20
  • I added the error if that gets returned if I add a new Pair to fix the overall structure – Darius Oct 14 at 11:25
  • 1
    The value for (contract %k (pair (pair (mutez %newCustBal) (mutez %newMerchBal)) (pair (bytes %newRevLock) (bool %valid)))) should be "KT1.."; not something else. – FFF Oct 14 at 13:27
  • Great, that worked, thanks! – Darius Oct 14 at 13:39
0

Ah okay, so the value for contract %k (pair (pair... should just be the contract and entrypoint, ie "KT1DskKf2HwDqoiL45PWZ7d72pn2jhfNxoos%receiveCall"

Thanks FFF!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.