# Godot

> This page shows how to add and use any regular C#/.NET SDK (distributed as a NuGet package or a DLL) inside a Godot 4 project that uses C#. It assumes you’re using the **.NET build** of the Godot editor.

## Prerequisites

* Install the **Godot .NET** editor build (not the standard build) ([Godot Engine Documentation](https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/index.html))
* Install **.NET SDK 8.0 or newer** (Godot 4.4 targets .NET 8 by default, but .NET 9.0 is also supported and recommended) ([Godot Engine](https://godotengine.org/article/godotsharp-packages-net8), [Godot Engine Documentation](https://docs.godotengine.org/en/4.3/development/compiling/compiling_with_mono.html))
* An IDE that supports C# (VS Code, Rider, or Visual Studio)

## Create or enable a C# project

1. Open Godot (.NET) → create a project
2. Add your first C# script (Godot will generate a `*.csproj` for you)
3. Build once to let Godot restore packages and generate bindings ([Godot Engine Documentation](https://docs.godotengine.org/en/4.3/tutorials/scripting/c_sharp/c_sharp_basics.html))

## Add Phantasma Phoenix C# SDK

### Option A — via NuGet (recommended)

From your project folder (where the `.csproj` lives), add the package (PhantasmaPhoenix.Cryptography shown here as an example, check [this](setup) page for full list of available packages):

```bash
dotnet add package PhantasmaPhoenix.Cryptography
dotnet restore
```

Godot C# uses standard .NET projects, so NuGet packages work the same way as in any C# app ([Godot Engine Documentation](https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/index.html))

### Option B — reference a local DLL

If you have a compiled `PhantasmaPhoenix.Cryptography.dll`, add a reference in your `.csproj`:

```xml
<ItemGroup>
  <Reference Include="PhantasmaPhoenix.Cryptography">
    <HintPath>addons/PhantasmaPhoenix.Cryptography.dll</HintPath>
  </Reference>
</ItemGroup>
```

Godot recognizes regular C# project references; external managed DLLs can be added in the `.csproj` file ([Godot Forums](https://godotforums.org/d/38934-how-to-reference-a-library-managed-dll-in-a-c-addon), [Reddit](https://www.reddit.com/r/godot/comments/19cck6e/how_to_use_c_godot_nodes_from_external_library))

## Minimal example

Create `Scripts/ExampleSdkUsage.cs` and attach it to a Node:

```csharp
using Godot;
using PhantasmaPhoenix.Cryptography;

public partial class ExampleSdkUsage : Node
{
    public override void _Ready()
    {
       	var keys = PhantasmaKeys.Generate();
        GD.Print($"Address: {keys.Address.Text}");
    }
}
```

Build the project (from IDE or `dotnet build`) and run the scene. C# scripts and exported members behave like in regular Godot C# projects ([Godot Engine Documentation](https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/index.html))

## Exporting the game (with C#)

1. Install export templates in Godot
2. Configure an export preset (Windows, Linux, macOS, Android, iOS)
3. Export your build

See **Exporting projects** in the official docs for platform setup and templates ([Godot Engine Documentation](https://docs.godotengine.org/en/latest/tutorials/export/exporting_projects.html))

> Note: Web (HTML5) export with C# is not supported in Godot 4.x at the time of writing ([Godot Forum](https://forum.godotengine.org/t/c-godot-4-and-html5-possible-when/97253))

## Tips & troubleshooting

*   Make sure your project targets **`net9.0`** in the `.csproj` when using Godot 4.4 packages:

    ```xml
    <PropertyGroup>
      <TargetFramework>net9.0</TargetFramework>
    </PropertyGroup>
    ```

    Details: GodotSharp packages moved to .NET 8 in 4.4 ([Godot Engine](https://godotengine.org/article/godotsharp-packages-net8))
* If NuGet restore fails, verify your **NuGet configuration** or regenerate `NuGet.Config` (common fix for `Godot.NET.Sdk` not found) ([Reddit](https://www.reddit.com/r/godot/comments/1f1kucp/why_is_so_hard_to_make_godot_43_c_working_i))
* Godot uses the `Godot.NET.Sdk` MSBuild SDK in your `.csproj` (managed by Godot) ([NuGet](https://www.nuget.org/packages/Godot.NET.Sdk))
* General C#/.NET how‑to for Godot (language features, exports, etc.) is covered in the official C# docs ([Godot Engine Documentation](https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/index.html))

## Useful links

* Godot C#/.NET docs (overview & basics) ([Godot Engine Documentation](https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/index.html))
* C# basics (4.4) and exports (attributes) ([Godot Engine Documentation](https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/c_sharp_basics.html))
* Exporting projects (templates & presets) ([Godot Engine Documentation](https://docs.godotengine.org/en/latest/tutorials/export/exporting_projects.html))
* GodotSharp packages & .NET 8 note (Godot 4.4) ([Godot Engine](https://godotengine.org/article/godotsharp-packages-net8))
* Platform state of C# in Godot 4.x (what “standard .NET” means) ([Godot Engine](https://godotengine.org/article/platform-state-in-csharp-for-godot-4-2))

***
