function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
require(key.token0 < key.token1);
pool = address(
uint256(
keccak256(
abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encode(key.token0, key.token1, key.fee)),
POOL_INIT_CODE_HASH
)
)
)
);
}
合约里面 uint256转address可以用address(uint256),但需要address转成uint256又改怎么写呢? 如果是在js里面互转是用什么方法?
address(57896044618658097711785492504451499836465512412780742056059170478185526900045)
在合约里面转address得到结果是0x12D6867FA648d269835cf69B49F125147754B54d 如果使用
uint256(uint160(0x12D6867FA648d269835cf69B49F125147754B54d))
得到的却是107545909830520079960460036330378474228962080077