{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "verifyingContract", type: "address" },
{ name: "salt", type: "bytes32" },
const metaTransactionType = [
{ name: "nonce", type: "uint256" },
{ name: "from", type: "address" },
{ name: "functionSignature", type: "bytes" },
verifyingContract: config.contract.address,
salt: "0x" + (42).toString(16).padStart(64, "0"),
const contractInstance = await new web3.eth.Contract(
config.contract.abi as AbiItem[],
const web3 = new Web3(biconomy.provider);
let nonce = await contractInstance.methods.getNonce(address).call();
let functionSignature = await contractInstance.methods
functionSignature: functionSignature,
const dataToSign = JSON.stringify({
EIP712Domain: domainType,
MetaTransaction: metaTransactionType,
primaryType: "MetaTransaction",
web3.currentProvider.send(
method: "eth_signTypedData_v4",
params: [address, dataToSign],
let { r, s, v } = (signature: any) => {
if (!ethers.utils.isHexString(signature)) {
'Given value "'.concat(signature, '" is not a valid hex string.')
const r = signature.slice(0, 66);
const s = "0x".concat(signature.slice(66, 130));
let v = "0x".concat(signature.slice(130, 132));
v = ethers.BigNumber.from(v).toString();
if (![27, 28].includes(Number(v))) v += 27;
const contractInstance = new web3.eth.Contract(
await contractInstance.methods
.executeMetaTransaction(userAddress, functionData, r, s, v)
// Listen to transaction updates:
biconomy.on("txHashGenerated", data: { transactionId: string; transactionHash: string; }) => {
showSuccessMessage(`tx hash ${data.hash}`);
biconomy.on("txMined", (data: {msg: string; id: string; hash: string; receipt: string}) => {
biconomy.on("onError", (data: {error: any; transactionId: string}) => {
bicnomy.on("txHashChanged", (data: {transactionId: string, transactionHash: string}) => {