Create a survey app that reward with an ERC20 token


I am creating a test app that reward users that complete a survey with an ERC20 token. I already have the ERC20 smart contract with a token supply of 5000000 token and the survey app in react and javascript. I want to link the two together so when a user click on submit, they receive 10 token from the initial wallet address.

Thank you very much.

1 Like

Congrats for your project. Great idea. pls send me the Link of your App. Wishing . .


I just need help to create the reward function in solidity. This is what i did, but it is not working.

mapping(uint => Reward) public rewards;

struct Reward{
uint id;
uint tokenReward;
address payable author;

event  UserRewarded(
    uint id,
    string content,
    uint tokenReward,
    address payable author

constructor() ERC20("MyTestToken", "MTT") {
    _mint(msg.sender, 7000000000000000000000000);

function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
    _transfer(_msgSender(), recipient, amount);
    return true;

function rewardUser(uint _id) public payable {
   //Make sure Id is valid
   require(_id > 0);
   // Fetch reward
   Reward memory _reward = rewards[_id];
   // Fetch the user
   address payable _user =;
   //Pay user by sending them MTT
   // Increment the reward amount
   _reward.tokenReward = _reward.tokenReward + msg.value;
   // Trigger event
   emit UserRewarded(_id, _reward.content, _reward.tokenReward, Reward._author);

    //   transfer(recipient, 10 * 10^18);
    //  address(recipient).transfer(msg.value);


thank you

Hey, welcome! :wave:

It seems like your target is to reward some token, but for your code just like above, it means you want to reward ETH. I think it should be token.transfer(to, amount)

Hi Skyge,

Yes i want to reward with the token that i created. So it is just a simple transfer function right? I don't need all of this?

Thank you.