it seems like I have a wrong gnache or truffle setup ...

I already ask a simular question here: Owner of contract is set to contract address?

Basicly there is some mess up with addresses on my local chain (it works on testnet).

The setup/migration is the same like in the link.

The actual functions:

    function claim(uint256 pid, uint256 cAmount, address test) external nonReentrant returns (bool){
        return _claim(pid, cAmount, test);

    function _claim(uint256 pid, uint256 cAmount, address test) internal returns (bool){
        require(test == msg.sender, "ERROR");
        bool success;
        uint256 possibleClaim = _getClaimableAmount(pid, test);
        require(possibleClaim >= cAmount, "Claim: Not enough claimable amount");
        uint256 tempDaoFee = cAmount.mul(_poolInfo[pid].claimFee);
        uint256 daoFee = tempDaoFee.div(100);
        success = IERC20(_poolInfo[pid].poolT.rewardToken).transfer(test, cAmount.sub(daoFee));
        _poolInfo[pid].poolT.rewardToken.transfer(_poolInfo[pid].daoWallet, daoFee);
        return success;

the test:

it("7.1 Claim: ...", async ()=> {
        const adr = await irs.getRewardToken("0");

        console.log("Address: ",adr)
        console.log("TokenAddress: ", iwbtc.address)
        console.log("ContractAddress: ", irs.address)

        const balanceOFContract0 = await iwbtc.balanceOf(irs.address);
        const bal0 = await iwbtc.balanceOf(accounts[6])

        console.log("balanceOFContract = ", balanceOFContract0.toString())
        console.log("balanceBeforClaim = ", bal0.toString())

        const claimable = await irs.getClaimableAmount("0",accounts[6]);
        const val = claimable / 2;

        console.log("Val = ", val.toString())

        const success = await irs.claim("0",val,accounts[6], {from: accounts[6]});

        const bal1 = await iwbtc.balanceOf(accounts[6])
        const balanceOFContract1 = await iwbtc.balanceOf(irs.address);

        console.log("balanceOFContract = ", balanceOFContract1.toString())
        console.log("balanceBeforClaim = ", bal1.toString())
        console.log("Transaction:", success)


the output:

Address:  0xFFCb10BeEE65E616cc231e1760C1FdBcb70ce821
TokenAddress:  0xFFCb10BeEE65E616cc231e1760C1FdBcb70ce821
ContractAddress:  0xdCA8a4625c00f739Adc6F245DaC8E1d5cB5fd06A
balanceOFContract =  154000
balanceBeforClaim =  70000
Val =  70000
balanceOFContract =  84000
balanceAfterClaim =  70000
Transaction: {
  tx: '0xe455ce4e24fe1aaeaa0d82dec41ffe5fedb647832dcc5421babd25aae44f901e',
  receipt: {
    transactionHash: '0xe455ce4e24fe1aaeaa0d82dec41ffe5fedb647832dcc5421babd25aae44f901e',
    transactionIndex: 0,
    blockHash: '0x8538f51b7266acc730e3e5bd344e5bbe2c67f335f8c427c40454751dee42e73a',
    blockNumber: 538,
    from: '0xb8917e63f9d6603366ff30871610f9af48804557',
    to: '0xdca8a4625c00f739adc6f245dac8e1d5cb5fd06a',
    gasUsed: 218583,
    cumulativeGasUsed: 218583,
    contractAddress: null,
    logs: [],
    status: true,
    logsBloom: '0x00000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000010000000000000000000000000000000100000000000000000000000000400000000000000000000000010000000000000000000000000400000001000000000000000000000000000000000000000000000000000000000000000000000000000000040000000020400000000000000000002000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000020001000000000000000000000',        
    rawLogs: [ [Object], [Object] ]
  logs: []
    √ 7.1 Claim: ... (3795ms)

So ...

  1. The transaction happen but the sender dont recieve the funds but the contract sended it.
  2. The msg.sender is the givin parameter... (require in the _claim) dont get the fund and is not in the transaction

Tryed around with IERC20() and without ... no difference (would make me wonder anyway).

Anyone any idea what is happening here?

  • Can you add an event that logs daoFee, cAmount, and _poolInfo[pid].poolT.rewardToken? What's the source code of iwbtc? How is it created? – Ismael Apr 13 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.