I have a function like this

    def _verifySigPersonalSign(self,req,sig):
        sp.verify((req.deadline != sp.timestamp(0)) | (sp.now<=req.deadline), "request expired")
        digest = sp.sha256(sp.pack(sp.record(sender=req.sender,to=req.to,token=req.token,txGas=req.txGas,tokenGasPrice=req.tokenGasPrice,batchId=req.batchId,nonce=self.data.nonces[req.sender][req.batchId],deadline=req.deadline,data=sp.sha256(req.data))));

and created a test for it :

req = sp.TRecord(sender=alice.public_key,to=bob.public_key,token=sp.address("tz1YtuZ4vhzzn7ssCt93Put8U9UJDdvCXci4"),txGas=1,tokenGasPrice=2,batchId=1,batchNonce=2,deadline=sp.timestamp(1),bytes=sp.pack('42'))
        secanrio += c1._verifySigPersonalSign(req,AliceSignature)

But I am receiving an error:

Error: Type Error
sp.TKey is not sp.TAddress
sp.check_signature (params.req.sender : sp.TAddress)

on the line last line of the code : sp.verify(sp.check_signature(req.sender,sig,digest)). I need this line in my contract and also tried some debugging and found if I comment out this line then I receive another error:

Error: : Cannot read property '$nat' of undefined

Traceback (most recent call last):

Can someone please help me resolve it?

1 Answer 1


Here is an example with the correct syntax, I hope this helps. Contract Link

The first issue you are having is with the way you call the entrypoint.

It should be c1._verifySigPersonalSign(req = req, sig = AliceSignature) instead of c1._verifySigPersonalSign(req,AliceSignature)

The second issue is because you are trying to create a record from a type definition:

It should be sp.record(...) instead of sp.TRecord(...)

  • Sorry rodrigo, the second issue gets solved but the first one still occurs with the same message
    – fuzious
    Commented Dec 1, 2020 at 12:19
  • 1
    Take a close look at the link I posted in the answer above. (It contains a working example of what you are trying to achieve) Commented Dec 1, 2020 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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