Generate Signatures
Generate a typed signature using new rpc calls
In order to generate EIP-712 compatible signatures we will use rpc method eth_signTypedData_v4 The method parallels eth_sign
There are other rpc methods too namely eth_signTypedData, eth_signTypedData_v2, eth_signTypedData_v3 but latest version of this rpc method is eth_signTypedData_v4
1
web3.currentProvider.sendAsync(
2
{
3
jsonrpc: "2.0",
4
id: 999999999999,
5
method: "eth_signTypedData_v4",
6
params: [userAddress, dataToSign]
7
},
8
function(err, result) {
9
if (err) {
10
return console.error(err);
11
}
12
const signature = result.result.substring(2);
13
const r = "0x" + signature.substring(0, 64);
14
const s = "0x" + signature.substring(64, 128);
15
const v = parseInt(signature.substring(128, 130), 16);
16
}
17
18
await myContract.methods
19
.setQuoteMeta(userAddress, "A DApp is cooler with Meta Transactions", r, s, v)
20
.send({
21
from: userAddress
22
});
23
);
Copied!
To understand Ethereum signatures in detail, refer to this article​
Checkout the full working code here https://github.com/bcnmy/dapp-demo​
Watch the demo in Action at https://dapp.biconomy.io/​
Now we have enabled native meta transactions in our DApp, let's integrate Biconomy for making our DApp gasless so uses can interact with it without having any ether in their wallet.
Last modified 1yr ago
Copy link