Skip to content
🎉 Welcome to the new Aptos Docs! Click here to submit feedback!
BuildSDKs.NET SDKGodot Integration

This integration is currently in beta. Please report any issues you encounter by creating an issue in the aptos-labs/aptos-dotnet-sdk repository.

Integrating into Godot projects

This guide will walk you through the process of integrating the Aptos .NET SDK. To install the Aptos SDK into your Godot project, you will need to add the Aptos SDK into your Godot project’s .csproj file.

Find the .csproj

In the root of your Godot project, find the .csproj file. This file is used to configure your Godot project and is used by the Godot build system. You can find this file by clicking on res:// in the Godot editor and selecting Open in File Manager.

If you can’t find the .csproj file, you can create a .cs file and build the application one time and it should be generated.


Open in File Manager

Add the Aptos NuGet package

Add the following line to the <ItemGroup> section of the .csproj file. If it doesn’t exist, create it the <ItemGroup> section.

.csproj
<ItemGroup>
  <PackageReference Include="Aptos" Version="0.0.2-beta" />
</ItemGroup>

It should look something like this:

.csproj
<Project Sdk="Godot.NET.Sdk/4.3.0">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
    <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
    <EnableDynamicLoading>true</EnableDynamicLoading>
    <RootNamespace>AptosSDKExample</RootNamespace>
  </PropertyGroup>
 
  <!-- START: Add these lines -->
  <ItemGroup>
    <PackageReference Include="Aptos" Version="0.0.1-beta" />
  </ItemGroup>
  <!-- END -->
 
</Project>

Use the Aptos SDK

Import the Aptos namespace in your C# script and use the SDK.

Example.cs
using Godot;
using System;
using Aptos;
 
public partial class Example : Node
{
	public override void _Ready()
	{
        PrintLedgerInfo();
	}
 
	async void PrintLedgerInfo() {
        var client = new AptosClient(Networks.Mainnet);
        var ledgerInfo = await client.Block.GetLedgerInfo();
        GD.Print(ledgerInfo.BlockHeight);
	}
 
}

Next Steps

You’ve successfully integrated the Aptos .NET SDK into your Godot project. Now you can start building your game and interacting with the Aptos blockchain. Below are some resources to help you get started.