Let's assume we have a frontier-based node with smart contract X
. From an off-chain worker, we want to call X.some_method()
which will return data, and then the worker would use this data to make some business decisions and submit a transaction back to update the contract state. Would that be possible by directly calling the evm pallet from the off-chain worker, without the need to make RPC calls?
1 Answer
I don't know much about EVM and Frontier, but in general offchain workers cannot write to the state directly, so if they call into a function directly that has some side effect, it will be ignored. The only way for them to write to state is to emit a transaction back to the local node and the rest of the network.
Thus,
Would that be possible by directly calling the evm pallet from the off-chain worker, without the need to make RPC calls?
I believe no.
-
OK, but couldn't such transaction be emitted by a mere function call in Rust, instead of making an HTTP request? Commented Oct 18, 2022 at 11:03
-
2Yes, there are helper functions made for offchain workers to send both signed and unsigned transactions: paritytech.github.io/substrate/master/frame_system/offchain/… Commented Oct 18, 2022 at 13:35