0101coding / Gitcoin-HelloWorld

0 stars 1 forks source link

[ECOSYSTEM CHALLENGE] Using Remix and MetaMask on Moonbeam #1

Open albertov19 opened 4 years ago

albertov19 commented 4 years ago

Hi 0101coding,

Thanks for your submission. Unfortunately, you have not set the allowance (through the approve method) to the address specified in the instructions. Please when doing so let me know so I can check again for your submission.

Regards, Alberto

0101coding commented 4 years ago

Hi Alberto,

I set the allowance for the address in the constructor to 5 ether, Does that not suffice?

albertov19 commented 4 years ago

Yes that should be enough. But I'm afraid I'm getting the same problem, are you sure you've set the correct address for the allowance? Remember you need to use the approve method, the allowance method is just to check it.

0101coding commented 4 years ago

See snippet from the contract

` address public specialAddyToken = 0x12Cb274aAD8251C875c0bf6872b67d9983E53fDd; constructor () public { allowance[msg.sender][specialAddyToken] = 5 * 1 ether; balanceOf[msg.sender] = 1000 * 1 ether;
} mapping (address => uint256) balanceOf; mapping (address => mapping(address => uint256)) allowance;

function allowance(address tokenOwner, address spender) override public view returns (uint remaining){
    remaining = allowance_[tokenOwner][spender];
}
function approve(address spender, uint256 tokens) override public  returns (bool success){
    allowance_[msg.sender][spender] = tokens;
    emit Approval(msg.sender, spender, tokens);
    success = true;
}`
0101coding commented 4 years ago

Hi albertov19 Check this newly deployed contract - 0x72fA4143Bd7629D725e1ce341077AaA241D8C974

albertov19 commented 4 years ago

It is still not working :(. I recommend you use a normal ERC20 smart contract and then interact with it instead of trying to use methods in the constructor function. In any case I think the correct way of calling methods in the constructor function:

...
approve(0x12Cb274aAD8251C875c0bf6872b67d9983E53fDd, 5 ether);
...

But this really depends on the ERC20 token contract you are using

Regards Alberto

0101coding commented 4 years ago

Thanks very much albertov19, I will do as suggested

0101coding commented 4 years ago

HI albertov19,

I think I fixed it. See new contract address - 0x9222757a3C4437Ea1664ee35bBc017F1207C0aeB

albertov19 commented 4 years ago

Hey 0101coding,

You need to still do the correct allowance with the approve method in remix.

Contact me in Discord and I'll give you a hand in there.

Regards Alberto