Timeline for Calling function on ERC20 contract through staticcall gives wrong result
Current License: CC BY-SA 4.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 22, 2019 at 11:30 | vote | accept | Johan | ||
Nov 22, 2019 at 11:26 | answer | added | Mikhail Vladimirov | timeline score: 1 | |
Nov 22, 2019 at 11:17 | vote | accept | Johan | ||
Nov 22, 2019 at 11:30 | |||||
Nov 22, 2019 at 10:59 | comment | added | goodvibration | OK, so I have un-deleted my answer (which I had posted prior to your confirmation of this, but wasn't sure that it would work). The shift is in order to get the (32-bit) function selector out of the (256-bit) hash. | |
Nov 22, 2019 at 8:41 | comment | added | Johan | @goodvibration changed to encodeWithSelector without the byteshiftyness and it works! What is the byte shifting for? ( the ">> (256 - 4 * 8)" part of your comment ) | |
Nov 22, 2019 at 8:36 | comment | added | Johan | @goodvibration i changed some variable names for improved readability, and missed a yaya. | |
Nov 22, 2019 at 8:35 | comment | added | Johan | @MikhailVladimirov no, im calling balanceOf on _address with a static call. | |
Nov 22, 2019 at 8:33 | history | edited | Johan | CC BY-SA 4.0 |
fixed var name
|
Nov 22, 2019 at 7:32 | comment | added | Mikhail Vladimirov |
You are not passing _address to balancOf in your static call.
|
|
Nov 22, 2019 at 7:11 | comment | added | goodvibration |
Also, I'm not sure what yaya means in your code, but I believe that you should be using sender there.
|
|
Nov 22, 2019 at 7:01 | comment | added | goodvibration |
Also, I believe that you should change abi.encode(bytes4(keccak256("balanceOf(address)")) to abi.encodeWithSelector(bytes4(uint256(keccak256("balanceOf(address)") >> (256 - 4 * 8))) , though I'm not entirely sure about this.
|
|
Nov 22, 2019 at 6:53 | answer | added | goodvibration | timeline score: 0 | |
Nov 22, 2019 at 6:27 | comment | added | goodvibration |
Side note: I'm pretty sure that you should do uint256(10) ** DECIMALS instead of 10 ** uint256(DECIMALS) . Also, instead of multiplying by 10000, you could use (DECIMALS + 4) . Lastly, you should use small letters for those 3 constants (name , symbol and decimals ), otherwise you contract is not conforming to the ERC20 standards, and applications will not display your contract details (including details of transactions executed on your contract) correctly.
|
|
Nov 22, 2019 at 0:05 | review | First posts | |||
Nov 22, 2019 at 1:09 | |||||
Nov 22, 2019 at 0:00 | history | asked | Johan | CC BY-SA 4.0 |