how to instantiate in an extension?

i am trying to instantiate a prefab inside an extension:

public static class ChickenExtension {
  public static GameObject eggPrefab;
	
  public static void LayEgg(this Chicken chicken) {      
    Instantiate(eggPrefab);
  }
}

i get the error:

error CS0103: The name `Instantiate’ does not exist in the current context

i believe the reason has to do with the ChickenExtension class not deriving from mono, but since an extension requires a static class, i cannot derive it from mono either. how should i go about doing this?

Instantiate method is inherited from UnityEngine.Object. Because your class ChickenExtension is not derived from UnityEngine.Object, you need to add:

using UnityEngine;

and call the method like this:

GameObject.Instantiate(eggPrefab);