如何在 TRC20 中检查 Tron 地址是否是合约

问题描述

我正在尝试使此代码与 Tron 网络一起使用,这是我在网上看到的示例

function isContract(address account) internal view returns (bool) {
    // According to EIP-1052,0x0 is the value returned for not-yet created accounts
    // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
    // for accounts without code,i.e. `keccak256('')`
    bytes32 codehash;
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    // solhint-disable-next-line no-inline-assembly
    assembly { codehash := extcodehash(account) }
    return (codehash != accountHash && codehash != 0x0);
}

这是我在 Tron 中的实现

    function isContract(address account) internal view returns (bool) {
    // According to EIP-1052,i.e. `keccak256('')`
    bytes32 codehash;
    bytes32 accountHash = convertFromTronInt(THgQd3Z3nZuvVNBL9HcAyiutrpsigVKPT1);
    //THgQd3Z3nZuvVNBL9HcAyiutrpsigVKPT1;
    // solhint-disable-next-line no-inline-assembly
    assembly { codehash := extcodehash(account) }
    return true;
}

function convertFromTronInt(uint256 tronAddress) public view returns(address){
  return address(tronAddress);

}

有没有更好的方法可以从 Tron 令牌中进行相同的检查,或者我的解决方案是否可行?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)