【发布时间】:2021-09-22 00:51:24
【问题描述】:
我正在使用 ethers-rs 编写一个 defi 应用程序。我需要计算 rust 中的 CREATE2 地址。我在 rust 中找不到 abi.encodePacked(token0, token1) 的等价物。
Uniswap 库中使用的代码(https://vomtom.at/how-to-use-uniswap-v2-as-a-developer):
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
很遗憾,我没有从互联网上得到太多帮助。
abi.encodePacked 在 rust 中的等价物是什么。
问候。
【问题讨论】:
标签: rust ethereum go-ethereum ethers.js