python - 通过 eth 地址确定合约地址
问题描述
我想知道为什么我不能制作正确的以太坊合约地址。我遵循了https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed中的代码
结果:
def mk_contract_address(sender: str, nonce: int) -> str:
"""Create a contract address using eth-utils.
# https://ethereum.stackexchange.com/a/761/620
"""
sender_bytes = to_bytes(hexstr=sender)
raw = rlp.encode([sender_bytes, nonce])
h = keccak(raw)
address_bytes = h[12:]
return to_checksum_address(address_bytes)
print(to_checksum_address(mk_contract_address(to_checksum_address("0xCcE984c41630878b91E20c416dA3F308855E87E2"), 0)))
但返回:
0x10f08E4A832891f27A170031536cAdd3B190D250
正确的结果是:
0xdac17f958d2ee523a2206206994597c13d831ec7
问题是什么...
解决方案
推荐阅读
- html - 外部 div 背景可见 arround 内部 div 在 Chrome
- vb.net - LINQ to Entities 中的自定义函数?如何编写可接受的代码?
- postgresql - 全文搜索缺失词
- mysql - 进行 SQL 查询以给出这样的特定结果
- reactjs - 组件不会在路由更改时重新渲染
- visual-studio-code - Visual Studio Code 工作区可以与多个 Windows 一起使用吗?
- reactjs - 如何不在 mapdispatchtoprops 中使用 bindActionCreators?
- arrays - 如何解析这个未知的数组表示法?这个数组表示法来自什么语言?
- c++ - 以排序顺序在链表中插入多个元素时出现分段错误
- android - 警报对话框按钮具有不同的颜色集