このコードを 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);
}
これはトロン用の私の実装です
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 = 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 トークンから同じチェックを行うより良い方法はありますか、それとも私のソリューションは実行可能ですか?