2

Trying to understand EIP712 and signatures. Modeling my knowledge on uniswap v2/v3 which is using Permit function in their routers for swapping.

So my question is the following, as some wallet is asking you to sign some message, for uniswap example to approve some token spending, where is this signature stored exactly, having a hard time understanding this as there is no regular transaction?

2 Answers 2

3

EIP-712 is a standard for users to sign structured data that smart contracts can verify. As long as you don't submit the signature to a contract via a transaction, it has no effect. See it as an authorization that costs nothing to produce but is ineffective until sent to a contract that knows how to use it.

Let's take permit as an example. Permit works like approve. The difference is that permit accepts and EIP-712 signature and changes the allowance only if the signature is considered valid. This means that you can sign a permit and anyone else that has your signature could send it to the contract and change your allowance. This is useful because it allows you to pack multiple actions into a single tx.

Without permit, to transfer tokens to a contract:

  • send an approve tx to authorize the contract transferring funds from your balance to its balance
  • call the contract that will inside its code call a transfer moving tokens from you to the contract

With permit:

  • sign a permit with the same parameters you would have used for an approve
  • call the contract with the signature in the parameters, the contract uses the signature to increase your allowance then transfer funds from you to the contract

So only 1 tx for permit while 2 needed for approve.

0

1."where is this signature stored exactly"

it can be stored anywhere, you see when you interact with Dapps like uniswap, you are not interacting with blockchain directly, uniswap website/frontend acts as the proxy or bridge between you and the blockchain, the actions you made on the website sometimes may be transformed a little bit in their backend(off chain) and then forward to blockchain, so the signature can be stored in the frontend(browser) or their backend if they like to or they will just send it to blockchain as a parameter for function call so no necessary to store it.

2."there is no regular transaction"

correct, it's off chain actions, signature no need make transaction, that's why we have EIP2612

And you should be aware of the safety: you made a signature without pay the fee, but if you're interact with malicious dapp, you may lose all your money with this simple signature, how to protect yourself you may refer to the guidelines here.

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.