Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Filter Transaction with value #305

Open
massimilianochiodi opened this issue Sep 2, 2019 · 0 comments
Open

Filter Transaction with value #305

massimilianochiodi opened this issue Sep 2, 2019 · 0 comments

Comments

@massimilianochiodi
Copy link

massimilianochiodi commented Sep 2, 2019

I try to filter a private ethereum transaction by content value :

Content:
Web3swift.EventParserResult(eventName: "voted", transactionReceipt: nil, contractAddress: Web3swift.EthereumAddress(_address: "0x984c457078445a7e5c95014f35c2ed57455394e8", type: Web3swift.EthereumAddress.AddressType.normal), decodedResult: ["survey_id": 164, "name": "voted", "2": 2, "_address": Web3swift.EthereumAddress(_address: "0x49d5d3a96b34ac1053bfe0073338a93fa7982305", type: Web3swift.EthereumAddress.AddressType.normal), "0": 164, "1": Web3swift.EthereumAddress(_address: "0x49d5d3a96b34ac1053bfe0073338a93fa7982305", type: Web3swift.EthereumAddress.AddressType.normal), "3": <be7c7388 1bb54029 8cf6d0d2 0b440267 1cf4f288 d670496e 07fa8993 e45526d9>, "hash": <be7c7388 1bb54029 8cf6d0d2 0b440267 1cf4f288 d670496e 07fa8993 e45526d9>, "answer": 2], eventLog: Optional(Web3swift.EventLog(address: Web3swift.EthereumAddress(_address: "0x984c457078445a7e5c95014f35c2ed57455394e8", type: Web3swift.EthereumAddress.AddressType.normal), blockHash: 32 bytes, blockNumber: 1338585, data: 32 bytes, logIndex: 0, removed: false, topics: [32 bytes, 32 bytes, 32 bytes, 32 bytes], transactionHash: 32 bytes, transactionIndex: 0)))]

Filter : "survey_id": 164 in decodedResult array bloc.
I try :

Globale.shared.keystore = try! BIP32Keystore(
            mnemonics: Globale.shared.w!.mnemonics,
            password: Globale.shared.codicefiscale,
            mnemonicsPassword: "",
            language: .italian)!
        
        var filter = EventFilter()
        
        filter.fromBlock = .blockNumber(0)
        filter.toBlock = .latest
        let id = UInt256(164)
        let parametro = "0x" + id.description
        filter.parameterFilters = [[("\"survey_id\": " + parametro + ")")]]
        
        let contratto = Globale.shared.web3!.contract(costanti.abi, at: costanti.contratto )
        do {
            let eventParser = try contratto?.getIndexedEvents(eventName: "voted", filter: filter)
            print(eventParser.debugDescription)
        } catch {
            print("Errore : " + error.localizedDescription)
        }

But obtains all transaction of event type "voted"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant