0

I am working on crowdfunding website using the Ethereum blockchain that can create a campaign. I created an algorithm that creates a payable address, and it can be fundable.

function createMyFunDity(string memory _addressName)
        public
        checkDuplicateName(_addressName)
    {
        address caller = msg.sender;
        list_of_creators.push(caller);
        bytes32 hashedAddressName = keccak256(abi.encode(_addressName));
        hashedAddressList.push(hashedAddressName); // added  hashed to the array to comapre .
        bytes32 hashedString = keccak256(
            abi.encode(_addressName, msg.sender, block.timestamp)
        );
        address castedAddress = address(uint160(uint256(hashedString)));
        address payable funditeeAddress = payable(castedAddress);
        funditees.push(FunDitees(funditeeAddress, _addressName));
        listOfFunDityAddresses.push(funditeeAddress);
        nameToAddress[_addressName] = funditeeAddress;
        creatorToAddressCreated[caller] = funditeeAddress;
        addressCreatedToCreator[funditeeAddress] = caller;
    }

The problem right now is I can't withdraw from the address.

Zartaj Afser
  • 3,619
  • 1
  • 8
  • 25
Salem_
  • 1
  • What exactly is the question? What does address actually mean when you say I can't withdraw funds? You want to withdraw funds from the smart contract? – Zartaj Afser Mar 03 '23 at 09:45

1 Answers1

0

The function is randomly creating a 160 bits value that it is reinterpreted as an address. That is perfectly fine.

The problem is that to withdraw from an address it needs to be a contract with a withdraw function, or an EOA (external owned account) with a private key.

If you have to create wallets in a predictable way from an smart contract I'd suggest using CREATE2 opcode. Look at the answer for this question How is the address of an Ethereum contract computed?.

Ismael
  • 30,570
  • 21
  • 53
  • 96