Where to get a signature for smart contract interaction via block explorer?

Viewed 822

In BSC (Binance Smart Chain) contracts I often meet a signature parameter but I have no idea where to get it. If you think that it is a signature message which you need to sign with Metamask - it's not. It's just a one of parameters of the function I need to run.

Example can be found there, just look at the purchase function and you'll see signature as a last parameter - https://bscscan.com/address/0xabc306ae80595f6c7748b81d6c2efc48b32a9e22#writeContract

1 Answers

Signature is a result of signing a message with a private key.

Example from the web3 docs page:

  • message Hello world
  • signed with the private key of address 0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe
  • results in signature 0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400

A contract can then verify if the signature and message (or hash of the message) can be recovered back to the signer address (cannot get the private key).

For example the OpenZeppelin ECDSA library is a developer-friendly wrapper for the low-level (EVM assembly) recovery method.

Unfortunately the contract linked in the question is passing the signature to another unspecified contract for the recovery, so I was unable to find the specific message that they're validating against and the actual recovery snippet that they're using. However, you can find more info about the signing process and on-chain recovery in this answer (the mentioned v, r and s params are literally parts of the whole signature).

Related