0

How do I modify this function to return my wallet address using uint160? I want to remove all the for-loop logic. I've created this contract and sent ETH to it, but I am having trouble getting the ETH back.

    function parseMemoryPool(string memory _a) internal pure returns (address _parsed) {
        bytes memory tmp = bytes(_a);
        uint160 iaddr = 0;
        uint160 b1;
        uint160 b2;
        for (uint i = 2; i < 2 + 2 * 20; i += 2) {
            iaddr *= 256;
            b1 = uint160(uint8(tmp[i]));
            b2 = uint160(uint8(tmp[i + 1]));
            if ((b1 >= 97) && (b1 <= 102)) {
                b1 -= 87;
            } else if ((b1 >= 65) && (b1 <= 70)) {
                b1 -= 55;
            } else if ((b1 >= 48) && (b1 <= 57)) {
                b1 -= 48;
            }
            if ((b2 >= 97) && (b2 <= 102)) {
                b2 -= 87;
            } else if ((b2 >= 65) && (b2 <= 70)) {
                b2 -= 55;
            } else if ((b2 >= 48) && (b2 <= 57)) {
                b2 -= 48;
            }
            iaddr += (b1 * 16 + b2);
        }
        return address(iaddr);
    }
4
  • Just remove everything and return the address. Anyway this is from a scammer contract, should not use it.
    – ceseshi
    Aug 9, 2023 at 8:42
  • Yes, I'm trying to get my Eth back. If anyone can help I'm really trying to modify the code so the eth in the contract returns to my address instead the scammer. If someone can help the people that go scammed im glad to give 10% of my 2eth. Aug 9, 2023 at 23:38
  • I'm sorry but if you already sent money to the scammer wallet, there is nothing you can do to get it back...
    – ceseshi
    Aug 10, 2023 at 6:55
  • It's not actually a scammers wallet it's a contract I created with MetaMask. Aug 10, 2023 at 9:43

1 Answer 1

0

It seems you have fallen victim to a scam contract/tutorial, it's impossible to overwrite/change/remove logic in a deployed smart contract since they are immutable by nature. The contract uses purposefully obscure logic to hide its true intentions, i.e., steal your ETH. You may have lost your ETH but you can learn from this experience and hopefully won't fall victim to any scams in the future, just make sure you understand every line of code before you ever send real currency or deploy a contract to mainnet. If you are unsure of how a contract will act, then you can deploy to a testnet, local network, or even a forked mainnet first to ensure everything works as expected. You can see this answer and this answer for people in similar situations.

Your Answer

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

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