File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,11 @@ func (executor *scriptExecutor) executeScript() error {
203203 chainID := executor .ctx .Chain .ChainID ()
204204
205205 if executor .ctx .EVMEnabled {
206+ // Setup InternalEVM in both environments because:
207+ // - Scripts execute in ScriptRuntimeEnv
208+ // - But system contract invocations (e.g., getAccount().balance) use TxRuntimeEnv
209+
210+ // Setup InternalEVM in ScriptRuntimeEnv (for script execution)
206211 err := evm .SetupEnvironment (
207212 chainID ,
208213 executor .env ,
@@ -211,6 +216,21 @@ func (executor *scriptExecutor) executeScript() error {
211216 if err != nil {
212217 return err
213218 }
219+
220+ // Setup InternalEVM in TxRuntimeEnv (for system contract invocations)
221+ // This solves the problem where FlowServiceAccount (which imports EVM) needs
222+ // InternalEVM to be available during dependency checking when invoked via
223+ // system contracts (e.g., getAccount().balance). Without this, type checking
224+ // fails with "cannot find variable in this scope: `InternalEVM`" because
225+ // system contract invocations use TxRuntimeEnv, not ScriptRuntimeEnv.
226+ err = evm .SetupEnvironment (
227+ chainID ,
228+ executor .env ,
229+ rt .TxRuntimeEnv ,
230+ )
231+ if err != nil {
232+ return err
233+ }
214234 }
215235
216236 value , err := rt .ExecuteScript (
You can’t perform that action at this time.
0 commit comments