好日子,我在看合同地址的创建方式,这个过程似乎是相当确定的(取决于现在)。是否有一种方法可以获得尚未为特定的当前部署的契约的地址?类似于:
contractAddress = getAddress(nonce1, data, privateKey)我知道过去有一个提供这种工具的pyethereum库,但是它已经很长时间没有更新了,我希望使用一个更活跃的工具。
一如既往,感谢您的帮助!
发布于 2016-11-03 01:29:58
其他人可以添加其他答案,但是pyethereum仍然是活动的,并且这种类型的代码不会改变:
def mk_contract_address(sender, nonce):
return sha3(rlp.encode([normalize_address(sender), nonce]))[12:]私钥不需要,只需要发件人地址。但是,如果sender是未知的,则从OP的privateKey中,sender由以下方法计算:
def privtoaddr(x, extended=False):
if len(x) > 32:
x = decode_hex(x)
o = sha3(privtopub(x)[1:])[12:]
return add_checksum(o) if extended else o发布于 2018-10-23 17:39:40
在戈朗,使用ethereum/go-ethereum/crypto.CreateAddress。
func CreateAddress(creator common.Address, nonce uint64) common.Address
https://ethereum.stackexchange.com/questions/9776
复制相似问题