作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我试图检索我的智能合约生成的事件
var abi = [{
"constant": false,
"inputs": [{
"name": "_value",
"type": "int32"
}],
"name": "changeLowerTrigger",
"outputs": [],
"payable": false,
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "metric",
"outputs": [{
"name": "name",
"type": "string",
"value": "place_holder_metric_name_to_be_autogenerated"
}, {
"name": "value",
"type": "int32",
"value": "7"
}],
"payable": false,
"type": "function"
}, {
"constant": false,
"inputs": [{
"name": "_value",
"type": "int32"
}],
"name": "changeUpperTrigger",
"outputs": [],
"payable": false,
"type": "function"
}, {
"constant": false,
"inputs": [{
"name": "_value",
"type": "int32"
}],
"name": "update",
"outputs": [],
"payable": false,
"type": "function"
}, {
"anonymous": false,
"inputs": [{
"indexed": false,
"name": "_value",
"type": "int32"
}],
"name": "ValueChanged",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": false,
"name": "_alarm",
"type": "string"
}, {
"indexed": false,
"name": "_value",
"type": "int32"
}],
"name": "Alarm",
"type": "event"
}]
var MyContract = web3.eth.contract(abi);
var myContractInstance = MyContract.at(
'0x3B03c46Dfc878FeF9fAe8de4E32a6718f2E250e9');
var events = myContractInstance.allEvents();
// watch for changes
events.watch(function(error, event) {
if (!error)
console.log(event);
});
// Or pass a callback to start watching immediately
var events = myContractInstance.allEvents(function(error, log) {
console.log(err, log);
});
> events
{
callbacks: [function(error, log)],
filterId: "0xd6af6f5a7273fe21452f00c4682456",
getLogsCallbacks: [],
implementation: {
getLogs: function(),
newFilter: function(),
poll: function(),
uninstallFilter: function()
},
options: {
address: "0x3B03c46Dfc878FeF9fAe8de4E32a6718f2E250e9",
from: undefined,
fromBlock: undefined,
to: undefined,
toBlock: undefined,
topics: []
},
pollFilters: [],
requestManager: {
polls: {
0xd6af6f5a7273fe21452f00c4682456: {
data: {...},
id: "0xd6af6f5a7273fe21452f00c4682456",
callback: function(error, messages),
uninstall: function()
}
},
provider: {
newAccount: function(),
send: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
sendAsync: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
sign: function(),
unlockAccount: function()
},
timeout: {},
poll: function(),
reset: function(keepIsSyncing),
send: function(data),
sendAsync: function(data, callback),
sendBatch: function(data, callback),
setProvider: function(p),
startPolling: function(data, pollId, callback, uninstall),
stopPolling: function(pollId)
},
formatter: function(),
get: function(callback),
stopWatching: function(callback),
watch: function(callback)
}
最佳答案
您只需调用get()
在您获得并发布在答案中的结果对象上。它在官方文档中有描述,可以找到here
关于以太坊/Solidity 在 geth 控制台中获取智能合约事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44029634/
我是一名优秀的程序员,十分优秀!