Ich habe dieses Beispiel geschrieben, aber ich möchte bestimmte Ereignisse „unsealBid“ filtern und Ereignisse der Vergangenheit auflisten (z. B. die letzten 1 oder 2 Tage).
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/65386ae7c95b446c889a41405aec48e1');
const abi = [{ "constant": false, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "releaseDeed", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "getAllowedTime", "outputs": [{ "name": "timestamp", "type": "uint256" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "unhashedName", "type": "string" }], "name": "invalidateName", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [{ "name": "hash", "type": "bytes32" }, { "name": "owner", "type": "address" }, { "name": "value", "type": "uint256" }, { "name": "salt", "type": "bytes32" }], "name": "shaBid", "outputs": [{ "name": "sealedBid", "type": "bytes32" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "bidder", "type": "address" }, { "name": "seal", "type": "bytes32" }], "name": "cancelBid", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "entries", "outputs": [{ "name": "", "type": "uint8" }, { "name": "", "type": "address" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" }, { "name": "", "type": "uint256" }], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "ens", "outputs": [{ "name": "", "type": "address" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "_hash", "type": "bytes32" }, { "name": "_value", "type": "uint256" }, { "name": "_salt", "type": "bytes32" }], "name": "unsealBid", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "transferRegistrars", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "address" }, { "name": "", "type": "bytes32" }], "name": "sealedBids", "outputs": [{ "name": "", "type": "address" }], "payable": false, "type": "function" }, { "constant": true, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "state", "outputs": [{ "name": "", "type": "uint8" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "_hash", "type": "bytes32" }, { "name": "newOwner", "type": "address" }], "name": "transfer", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [{ "name": "_hash", "type": "bytes32" }, { "name": "_timestamp", "type": "uint256" }], "name": "isAllowed", "outputs": [{ "name": "allowed", "type": "bool" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "finalizeAuction", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "registryStarted", "outputs": [{ "name": "", "type": "uint256" }], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "launchLength", "outputs": [{ "name": "", "type": "uint32" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "sealedBid", "type": "bytes32" }], "name": "newBid", "outputs": [], "payable": true, "type": "function" }, { "constant": false, "inputs": [{ "name": "labels", "type": "bytes32[]" }], "name": "eraseNode", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "_hashes", "type": "bytes32[]" }], "name": "startAuctions", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "hash", "type": "bytes32" }, { "name": "deed", "type": "address" }, { "name": "registrationDate", "type": "uint256" }], "name": "acceptRegistrarTransfer", "outputs": [], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "_hash", "type": "bytes32" }], "name": "startAuction", "outputs": [], "payable": false, "type": "function" }, { "constant": true, "inputs": [], "name": "rootNode", "outputs": [{ "name": "", "type": "bytes32" }], "payable": false, "type": "function" }, { "constant": false, "inputs": [{ "name": "hashes", "type": "bytes32[]" }, { "name": "sealedBid", "type": "bytes32" }], "name": "startAuctionsAndBid", "outputs": [], "payable": true, "type": "function" }, { "inputs": [{ "name": "_ens", "type": "address" }, { "name": "_rootNode", "type": "bytes32" }, { "name": "_startDate", "type": "uint256" }], "payable": false, "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "hash", "type": "bytes32" }, { "indexed": false, "name": "registrationDate", "type": "uint256" }], "name": "AuctionStarted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "hash", "type": "bytes32" }, { "indexed": true, "name": "bidder", "type": "address" }, { "indexed": false, "name": "deposit", "type": "uint256" }], "name": "NewBid", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "hash", "type": "bytes32" }, { "indexed": true, "name": "owner", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" }, { "indexed": false, "name": "status", "type": "uint8" }], "name": "BidRevealed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "hash", "type": "bytes32" }, { "indexed": true, "name": "owner", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" }, { "indexed": false, "name": "registrationDate", "type": "uint256" }], "name": "HashRegistered", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "hash", "type": "bytes32" }, { "indexed": false, "name": "value", "type": "uint256" }], "name": "HashReleased", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "name": "hash", "type": "bytes32" }, { "indexed": true, "name": "name", "type": "string" }, { "indexed": false, "name": "value", "type": "uint256" }, { "indexed": false, "name": "registrationDate", "type": "uint256" }], "name": "HashInvalidated", "type": "event" }];
const address = '0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef';
const contact = new web3.eth.Contract(abi, address);
contact.getPastEvents('AllEvents',
{
//filter: {myIndexedParam: [1,44], myOtherIndexedParam: '0x47872b42'}, // Using an array means OR: e.g. 20 or 23
fromBlock: 6614389 ,
//fromBlock: web3.eth.getBlockNumber('latest') - (60 * 60 * 24 * 7) / 14,
toBlock: 'latest'
}, (err, events) => {
console.log(events);
})
Du kannst tun:
contact.BidRevealed({fromBlock: 6614389, toBlock: 'latest' }).get(function(err, logs){console.log(logs)}
Ahmed
Jaime
Ahmed
Jaime
Ahmed
Jaime
BidRevealed(bytes32 indexed hash, address indexed owner, uint value, uint8 status);
Siehe das Update zu meiner Antwort. Obwohl dies in Ihrer ursprünglichen Lösung funktionieren wird. Ihr Problem ist, dass Sie nach unsealBid suchen, aber das ist kein Ereignis, sondern suchenBidRevealed
und überprüfen Sie die Statusargumente des Protokolls.