Godot Integration
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 onres://
in the Godot editor and selectingOpen 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.
-
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.<ItemGroup><PackageReference Include="Aptos" Version="0.0.2-beta" /></ItemGroup>It should look something like this:
<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.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
Section titled “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.