the below solidity code converts 29144403828894911802891993729705329970730667872118118 to 0x690a87Ed8972e451e755b8F2dC1fc2B28e3c6566

I would like to reproduce this in python but have come up short. Can anyone point me in the right direction. or give me an idea of what the address() function is doing?

pragma solidity >=0.6.0 <0.8.0;

contract Simple {

    function getAddress(uint256 p) public  returns (address) {
        address pool = address(p);
        return pool;
  • address(p) is equivalent to address(uint160(p)), it trims the 256 bits number to 160 bits and returns it as address
    – ceseshi
    Commented Jun 15, 2023 at 15:49
  • 1
    Thanks you very much! Commented Jun 16, 2023 at 15:14

1 Answer 1


solved it

'0x' +Web3.to_hex(29144403828894911802891993729705329970730667872118118)[-40:]

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.