1

I know it sounds like a basic question (it should be), despite that I could not find any clear reference to that in polygon's (Matic) docs on how does payable(address).call works

pragma solidity ^0.7.6;

contract MyFirstPolygonContract {


    string private name;
    uint private amount;
    
    function sendFunds(address receiver) external payable {
        payable(receiver).call{value: msg.value}('');
    }

//set
    function setName(string memory newName) public {
        name = newName;
    }

//get
    function getName () public view returns (string memory) {
        return name;
    }
    
//set
    function setAmount(uint newAmount) public {
        amount = newAmount;      
    }

//get
    function getAmount() public view returns (uint) {
        return amount;
    }
}

I deployed this contract into Matic Mainnet in order to test sendFunds and quantify the amounts. I tried sending funds between two of my accounts sender_addr, recv_addr.

On Remix, I have chosen to send 1 ether on this contract (deployed on Matic). One Matic Token has been deducted from sender_addr. But the recv_addr received none !! It's been about 24 hours now. The transaction is not even shown on polygon scan !

It's worth noting that function sendFunds worked as expected on Mumbai testnet though.

EDITED:

The contracts are deployed in different networks having the same address 0x3918AaECf75aD253E0098fD0ee5C11d854BE9de6

I did that exact transaction on the testnet 0.1 MATIC https://explorer-mumbai.maticvigil.com/address/0x3918AaECf75aD253E0098fD0ee5C11d854BE9de6/transactions (this was successful)

While I did those two transactions added 1.001 MATIC on the matic mainnet https://polygonscan.com/address/0x3918aaecf75ad253e0098fd0ee5c11d854be9de6 (failed to send to recv_addr)

4
  • can you include your deployed contracts addresses of Matic and Mumbai both?
    – hack3r-0m
    Jun 22, 2021 at 9:48
  • @hack3r_0m you made me notice something I did not before, they have the same address !! It's true the contracts are the same but I did not expect them to take the same address ?! Jun 22, 2021 at 10:24
  • It is possible if deployer and nonce are exact the same (that's how contract address is calculated). check ethereum.stackexchange.com/questions/760/…
    – hack3r-0m
    Jun 22, 2021 at 10:48
  • I get it now, it's just weird that the nonce wasnt refreshed between deploy runs. Anyway, it's still doesn't affect the issue i am having because they are different networks. Jun 22, 2021 at 10:50

1 Answer 1

2
+50

The issue is that your contract is not deployed on Mainnet.

It is deployed on Testnet, but on Mainnet there is no contract code associated with the address.

You should try to deploy it again on Mainnet. As you know, if you use the same address and same nonce as on testnet, you should have the same address for your Mainnet contract.

If you want to receive the MATIC that you sent to the address back, you should add a withdraw function to your contract that transfers all the contract balance to msg.sender. Otherwise, this MATIC will be lost forever.

EDIT: I think that this is your contract on Mainnet. The address is not the same as on Testnet, althought they both start by 0x39! You called the wrong address on Mainnet.

3
  • Thank you, it turns out that everything in the code was right, it was just remix that for some reason mixed up and made me call the test contract and send the real matic in to that unintended contract. I loaded the real contract into remix by address and the transaction was successful. Jun 26, 2021 at 15:06
  • I cannot get the real matic wasted because I am not able to know the nonce that was used. Anyway you solved my issue which was related to getting the code done , despite that it was actually working anyway xD. Jun 26, 2021 at 15:09
  • The nonce on testnet was 22 (you can see it on the contract creation transaction in the explorer). On mainnet, your last tx was nonce 9.
    – Undead8
    Jun 30, 2021 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.