[英]Web3J “transaction.getTo()” returns null if sent to contract
I'm currently running a full node and am trying to loop through some transactions.我目前正在运行一个完整的节点,并试图循环一些事务。 Whenever I do so with Web3j and use the EthBlock.TransactionObject
and I get to a transaction that contains a contract ( Like this one ) and use the .getTo()
function it returns a null value.每当我使用 Web3j 执行此操作并使用EthBlock.TransactionObject
并且我得到一个包含合同的交易( 就像这个)并使用.getTo()
function 它返回一个 null 值。 Is there any way for me to retrieve the contract address?有什么办法可以找回合约地址吗?
EDIT: This is the code im using to get the transaction编辑:这是我用来获取交易的代码
EthBlock.Block block = web3.ethGetBlockByNumber(DefaultBlockParameter.valueOf(BigInteger.valueOf(1397553)), true).send().getBlock();
List<EthBlock.TransactionResult> transactionResults = block.getTransactions();
transactionResults.forEach(tx -> {
EthBlock.TransactionObject transaction = (EthBlock.TransactionObject) tx.get();
System.out.println(transaction.getCreates());
});
This returns a "null"这将返回一个“空”
When a transaction creates a contract, the to
field is empty by design (of the Ethereum network).当交易创建合约时, to
字段在设计上是空的(以太坊网络的)。
To get the contract address that the transaction creates, use the getCreates() method.要获取交易创建的合约地址,请使用getCreates()方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.