How to create smart contract using openzeppelin metatx relayer to receive and withdraw usdt erc20 token using metamask?

Here is what I need to do,

  1. Create a smart contract that can use a relayer account from Openzeppelin defender and do the gasless meta transactions. Which I already created and sent some Ethereum too.
  2. The contract can receive USDT erc20 funds, and show balance, and the contract owner can withdraw the funds.
  3. Then use Metamask in a react frontend and call those functions. Here the Metamask account will not pay the gas fees. Instead, the relayer will do.

The contract I created,

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

contract EtherWallet{
    address payable public owner;

    constructor() {
        owner =payable(msg.sender);
    }

    receive() external payable {}

    function withdraw(uint _amount) external {
        require(msg.sender == owner, "Only owner can withdraw");
        payable(msg.sender).transfer(_amount);

    }

    function getBalance() external view returns (uint) {
        return address(this).balance;
    }
}

But not sure how to do this. I need help with all the 3 options.

Hey @Md_Abu_Sayeed_Mondal,

You'll need to follow some extra steps in order to setup, but you are on a good track since you've already identified the steps to follow.

The details on how to create a MinimalForwarder, setup an Autotask webhook and calling from a frontend are well documented in this demo:

Hope it helps!

1 Like

Thanks. From this video, what is a minimalforwarder address?

I'm not sure if I'm misunderstanding your question, but I think you're referring to the address of a deployed MinimalForwarder contract you'll need to deploy.