'what is address of msg.sender when webjs proxy contract instance call logic contract abi?

In my test demo, I deployed a proxy at this proxy contract address, and I have a logic contract. When I used web3.js create a proxy contract at proxy contract with logic ABI, then call the logic contract function withdraw(address _recipient, address _tokenAddr, uint256 _amount) onlyWhitelisted public, what's the address of msg.sender in the called function of logic function? It's the user address or the address of proxy contract? In my logic contract, there is a public mapping(address => bool) whitelist. I want use whitelist[msg.sender] to check whether the original use address is in the whitelist. I have added my user address to the whitelist.But whitelist[msg.sender] always return false when via proxy contract to interactive with logic contract.



Solution 1:[1]

The proxy contract uses delegatecall() native function to redirect the request. Which also passes the original msg.sender.

what's the address of msg.sender in the called function of logic function

It's the original address that calls the proxy.


But whitelist[msg.sender] always return false when via proxy contract to interactive with logic contract.

When you're using a proxy contract, all storage values are stored on the proxy address - not on the logic address. So when you're querying value of whitelist[msg.sender], you need to use the ABI of the logic contract but the address of the proxy.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Petr Hejda