Hello!
We are developing a smart contract hooked to github users in order to give them some recompenses.
The trouble occurs when we are trying to do a transfer from a wallet minted with all the tokens to a user wallet.
We received an error that we were missing an 'approve' so we try with:
- Call the
_approveandapprovewith 3 or 2 parameters. - Call the
_approvewith owner and spender being the minted address. - Call the
_approvewith owner being the minted address and spender being msg.sender. - Call the
_approveandtransferFromwiththiswithoutthis
Our code is:
function rewardUser(string memory githubUser, GithubActions actionType) public returns(bool success) {
require(usersAddress[githubUser] != address(0), "Address not registered");
require(actionType >= GithubActions.issue_comment && actionType <= GithubActions.pull_request_review_comment, "Wrong action");
if(actionType == GithubActions.issue_comment) {
_approve(MINTED_ADDRESS, msg.sender, REWARD_ISSUE_COMMENT);
transferFrom(MINTED_ADDRESS, usersAddress[githubUser], REWARD_ISSUE_COMMENT);
emit RewardIssueComment(usersAddress[githubUser]);
}
else if(actionType == GithubActions.pull_request_review) {
_approve(MINTED_ADDRESS, msg.sender, REWARD_PULL_REQUEST_REVIEW);
transferFrom(MINTED_ADDRESS, usersAddress[githubUser], REWARD_PULL_REQUEST_REVIEW);
emit RewardPullRequestReview(usersAddress[githubUser]);
}
else if(actionType == GithubActions.pull_request_review_comment) {
_approve(MINTED_ADDRESS, msg.sender, REWARD_PULL_REQUEST_REVIEW_COMMENT);
transferFrom(MINTED_ADDRESS, usersAddress[githubUser], REWARD_PULL_REQUEST_REVIEW_COMMENT);
emit RewardPullRequestReviewComment(usersAddress[githubUser]);
}
return true;
}
Now we are having this problem:
Gas Estimation Execution Reverted (ERC20: transfer amount exceeds allowance)
We are using @openzepellin/contracts and hardhat.
We are using only the ERC.20 contract