0

I want to write javascript method for same

function predictDeterministicAddress(
    address implementation,
    bytes32 salt,
    address deployer
) internal pure returns (address predicted) {
    assembly {
        let ptr := mload(0x40)
        mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
        mstore(add(ptr, 0x14), shl(0x60, implementation))
        mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
        mstore(add(ptr, 0x38), shl(0x60, deployer))
        mstore(add(ptr, 0x4c), salt)
        mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
        predicted := keccak256(add(ptr, 0x37), 0x55)
    }
}
Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • I dont believe that you can call internal functions from the frontend. I would have to test that. – a6i09per5f May 19 '22 at 17:19
  • Other than that. What exactly is the problem when you call it from the frontend? I would say that you should use the regular call() function from the web3.js library. Have you worked with web3.js before? – a6i09per5f May 19 '22 at 17:22
  • btw, I cant verify if the assembler is correctly used, because I never used asm for solidity before. – a6i09per5f May 19 '22 at 17:24

0 Answers0