Events web3j不支持多个索引事件字段?
我拥有以太坊智能合约,功能如下:Events web3j不支持多个索引事件字段?,events,ethereum,solidity,smartcontracts,Events,Ethereum,Solidity,Smartcontracts,我拥有以太坊智能合约,功能如下: event onPledged(uint indexed featureKey, uint date, address backer, uint256 amount); ... function pledge(uint featureKey) public payable withState(featureKey, State.Funding) { ... // event onPledged(featureKey, n
event onPledged(uint indexed featureKey, uint date, address backer, uint256 amount);
...
function pledge(uint featureKey) public
payable
withState(featureKey, State.Funding)
{
...
// event
onPledged(featureKey, now, backer, pledgeAmount);
...
}
我正在进行java测试(使用web3j和web3j maven插件生成智能合约java包装器)来调用检查事件的质押()
:
// pledge
logger.info("Pledging by backer ...");
TransactionReceipt pledgeReceipt = pledgerContract.pledge(featureKey, fixedPledgeAmount).send();
List<AppetissimoContract.OnPledgedEventResponse> pledgedEvents = minerContract.getOnPledgedEvents(pledgeReceipt);
assertEquals(1, pledgedEvents.size()); // true
现在它失败了,因为没有事件(0):
在solidity中,最多可以为3个字段编制索引:
> Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.
这是个问题吗?使用
索引的属性是否需要更多气体(因此达到气体极限可能是原因)?这是web3j的一个突出优点。现在,为了解决这个问题,您必须将所有索引参数排在非索引参数之前。我隐约记得在某个地方读到,所有索引参数必须排在非索引参数之前,但我找不到支持这一点的文档(或者,我记得不正确)。您是否尝试过在日期
之前更改放置后台
的顺序?没有,我没有尝试过。在示例中,索引的变量通常是第一个,但我在文档中找不到。任何人
assertEquals(1, pledgedEvents.size()); // false, size() is 0
> Up to three parameters can receive the attribute indexed which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface.