我正在使用https://github.com/ethers-io/ethers.js/ 我有以下智能合约,
contract WhiteList {
event logAddressChange(address indexed purchaser, uint256 value, uint256 amount);
function changeContractAddress(address _purchaser, uint256 _whitelistCap)
public
returns (bool)
{
logAddressChange(_purchaser, _whitelistCap, _whitelistCap);
return true;
}
}
我正在尝试为 logAddressChange 事件开发一个节点 js 侦听器。我只想听那个事件。
我的节点服务器 js
app.listen(port, function() {
homeController.check_health();
});
我的节点 js 控制器
var config = require('config');
var ethers = require('ethers');
var providers = require('ethers').providers;
var network = providers.networks.rinkeby;
var infuraProvider = new providers.InfuraProvider(network);
var etherscanProvider = new providers.EtherscanProvider(network);
var fallbackProvider = new providers.FallbackProvider([
infuraProvider,
etherscanProvider
]);
var provider = providers.getDefaultProvider(network)
var contract_provider = config.get('contract_provider');
var contract_address = config.get('contract_address');
var contract_abi = config.get('contract_abi');
var account_private_key = config.get('account_private_key');
var account_address = config.get('account_address');
var crm_url = config.get('crm_url');
var wallet = new ethers.Wallet(account_private_key, provider);
var contract = new ethers.Contract(contract_address, contract_abi, wallet);
var provider_contract = new ethers.Contract(contract_address, contract_abi, provider);
var overrideOptions = {
gasLimit: 250000,
nonce: 0,
value: ethers.utils.parseEther('1.0')
};
exports.check_health = function(req, res) {
console.log('started event');
contract.events.onlogAddressChange = function(purchaser, value, amount) {
console.log('started event1');
console.log("purchaser:" + purchaser);
console.log("value:" + value);
console.log("amount:" + amount);
};
};
触发事件后我已经等了一个多小时,仍然没有。
我不知道我做错了什么。
你能帮忙吗?