Skip to main content
2 of 2
added code example
leonprou
  • 429
  • 1
  • 5
  • 11

I've found a straight forward way to solve it by extending the contract B ABI with the events of contract A. A is inside of B, so B can call to A methods and trigger A events. While A's methods are encapsulated, A's events are not. By this line of thinking in makes sense to include A's events in B.

This can be done manually by a copy-paste or with code:

const eventsA = extractEvents(AAbi)
const extendedAbi = [...BAbi, ...eventsA]
const contractB = new web3.eth.Contract(extendedAbi, address)
const receipt = await contractB.methods.B().send({ /* options */ })

or even in a more incautious way:

const extendedAbi = [...BAbi, ...AAbi]

Any thoughs about this pattern? Other solution?

leonprou
  • 429
  • 1
  • 5
  • 11