Modify Respective Function
Make a method which supports native meta transactions
Now using all the information from previous sections, let's make a new method that sets the quote from the user but this time we do it with native meta transaction support.
Create a new function to include the following params
userAddress
newQuote
sigR
sigS
sigV
Add an instance of the struct
Hash message in EIP712 compatible form
"\x19" makes the encoding deterministic
"\x01" is the version byte to make it compatible to EIP-191
Verify the Signatures On Chain
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)
recover the address associated with the public key from elliptic curve signature
Add the Necessary Logic
Increment Nonce for Replay Protection
Complete Code Snippet
Checkout the full working code here https://github.com/bcnmy/dapp-demo
Congratulations! You have successfully integrated meta transactions in your Smart Contracts
In the next section, Let's see what changes we need to do on the Client side.
Last updated