我们有一项活动如下:
event LogNewObject(address sender, bytes32 indexed id, bytes32 sub_states_types, bytes32 sub_states_values, address owner);在以下函数中调用此事件:
function newObject(bytes32 _id, uint256 number_of_sub_states, bytes32[10] sub_states_types, bytes32[10] sub_states_values, address _owner) public returns(bool success) {
require(!isObject(_id));
uint256 counter=0;
for(counter; counter < number_of_sub_states; counter++) {
objectStructs[_id].state.sub_state[sub_states_types[counter]] = sub_states_values[counter];
emit LogNewObject(msg.sender, _id, bytes32(sub_states_types[counter]), bytes32(sub_states_values[counter]), _owner);
}
objectStructs[_id].owner = _owner;
objectStructs[_id].isObject = true;
objectList.push(_id);
return true;
}我想得到像混合这样的日志,如下图所示:
为此,我使用以下命令:
contractInstance.events.LogNewObject({fromBlock: 0, toBlock: 'latest'}, function(error, event){ console.log(event); })我收到以下输出:
> contractInstance.events.LogNewObject({fromBlock: 0, toBlock: 'latest'}, function(error, event){ console.log(event); })
null
Subscription {
id: null,
callback: [Function],
arguments:
[ { fromBlock: '0x0',
toBlock: 'latest',
topics: [Array],
address: '0xe1623aaf57fcbe260f022404c730ae32aebe39f6' } ],
_reconnectIntervalId: null,
options:
{ subscription:
{ params: 1,
inputFormatter: [Array],
outputFormatter: [Function: bound ],
subscriptionHandler: [Function: subscriptionHandler] },
type: 'eth',
requestManager:
RequestManager {
provider: [HttpProvider],
providers: [Object],
subscriptions: {} } },
subscriptionMethod: 'logs' }正如您所看到的,输出并不像预期的那样。
我还使用了用户Jitendra Kumar. Balla提出的命令。但是,当我在我的问题中上传其屏幕快照时,我接收到的输出与混合日志输出的输出相同,而不是类似于它的输出。I期望这个输出:

必须将What选项添加到此命令中,才能接收类似于混合 output日志的输出,如上图所示?
发布于 2018-05-07 11:56:22
我建议您使用eventEmitter结构,它更容易管理和执行您想要做的事情:)
https://ethereum.stackexchange.com/questions/47794
复制相似问题