1

I have tried ganache and geth too for contracts deployment locally hosted port # 8545. A function of deployed contract is called from another smart contract (deployed locally on same port)

So its like ContractA func1() -> ContractB func2(p1,p2) { emit event!!! }

ContractA

ContractA obj = ContractA(0x034309b0de3af84089cbaf6bb7a5b6f657f9f0e5);
obj.triggerEvent(param1, param2);

while ContractB

function triggerEvent(uint param1, address param2)
    public {
    emit TotalInv(msg.sender, param1, param2);
 }

Now problem is I am trying to get this event in eventFilter as

  current_block = Web3(HTTPProvider('http://localhost:8545')).eth.getBlock('latest')
  event_filter = contractB_instance.eventFilter('TotalInv', {
            'fromBlock': 0,
            'toBlock': current_block['number']
        })

Other than this, I have created a simple function returning string in ContractB to check if instance of contractB is correct or not. And its working well, printing that string on console.

Env Details :

Python : 3.6.2

Geth : 1.8.15-stable-89451f7c

Truffle : 4.1.14

Windows 10

Web3.py : 4.6.0

Ganache : 1.1.0

  • Could you link to the documentation for eventFilter? I can't find it here. What is self.relayer? It looks like you're passing a dictionary to toBlock. You probably want to just pass the string "latest" or the number member of the return value of getBlock. – user19510 Sep 19 '18 at 14:13
  • Please say it once again: did you actually try deploying both contracts in a private blockchain running on geth, not in Truffle's development network, and then subscribing to events? – Utgarda Sep 19 '18 at 14:24
  • Sorry for being too much late, @smarx eventFilter is provided in PyDoc you can search here. Then "self.relayer" that was actual name of contractB_instance. About 'getBlock', you were right so I changed this to current_block['number']. But still no difference – faran ahmed Oct 8 '18 at 4:59
  • @Utgarda yes I have deployed both contracts in private blockchain GETH and Ganache too using Web3. Even after subscribing to the events I am not getting any event triggered. – faran ahmed Oct 8 '18 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.