0
votes

I am trying to save a variable that gets emmited by an event, from a function in another smart contract, that I’m calling, into a storage variable within my smart contract.

So my call looks something like this:

ExternalContract.foo(boo);

The event in ExternalContract that contains the desired variable:

emit Event(bytes desiredVariable)

So I want to save this variable in my contract without relying on an off-chain script. Is there even a way to do it?

1

1 Answers

0
votes

The Log and its event data is not accessible from within contracts (not even from the contract that created them).

Source: https://docs.soliditylang.org/en/v0.8.7/contracts.html#events

So unless there's a getter function for the desiredVariable, or unless it's stored in a public property (they have automatically generated getter functions as well), there's no way to get the event log value from a contract, and you'll need to use an off-chain app.