I have a public view function that performs some calculations on the given input and returns the result. Although smart contracts don't have a private key Is there any way to add a signature as proof that output is generated by the smart contract?

Can a function in smart contract return output along with digital signature so the client can verify that output was generated by smart contract?

1 Answer 1


Yes. It is EIP-1271: Standard Signature Validation Method for Contracts. You can find details here.

EIP-1271 is supported e.g. by Gnosis Multisig.

  • 1
    as I read about EIP-1271 it explains about isValidSignature for the signature verification. But how contract generates a digital signature for a given message? Commented Jul 4, 2021 at 14:06
  • How contract generates a digital signature for a given message It cannot do this without accessing Ethereum node. Whoever is responsible to check the validity of the message must call isValidSignature function. Thus, the validity of the signature is stored in the contract state. See github.com/gnosis/safe-contracts/blob/… Commented Jul 4, 2021 at 14:56
  • 1
    yes, I understood the isValidSignature part. I am curious to know how can a contract generate its signature on a given input. As you mentioned It cannot do this without accessing Ethereum node. How can it be done by accessing the node? Commented Jul 4, 2021 at 15:08
  • Please study the linked Gnosis SAFE implementation. The contract simply has mapping signature -> true for valid signatures, but your contract is free to implement whatever checking scheme you want. Commented Jul 4, 2021 at 15:19
  • 1
    I think the OP wants to know if a smart contract can generate a signature. As far as I know, because no one has access to the private key of the smart contract, it's not possible to let the smart contract "sign" anything.
    – Yao
    Commented Jan 22, 2023 at 9:06

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.