Aptos 0.0.2-beta
See the version list below for details.
dotnet add package Aptos --version 0.0.2-beta
NuGet\Install-Package Aptos -Version 0.0.2-beta
<PackageReference Include="Aptos" Version="0.0.2-beta" />
paket add Aptos --version 0.0.2-beta
#r "nuget: Aptos, 0.0.2-beta"
// Install Aptos as a Cake Addin #addin nuget:?package=Aptos&version=0.0.2-beta&prerelease // Install Aptos as a Cake Tool #tool nuget:?package=Aptos&version=0.0.2-beta&prerelease
C#/.NET SDK for Aptos (Beta)
Overview
The Aptos .NET SDK is a library that provides a convenient way to interact with the Aptos blockchain using C# under the .NET framework. The SDK is designed to offer all the necessary tools to build applications that interact with the Aptos blockchain.
Installation
The SDK is published onto NuGet where you can install it using the following command:
dotnet add package Aptos
Unity (WIP)
We are currently working on a
.unitypackage
for Unity developers. In the meantime, you can use the NuGet package manager to install the SDK into your Unity project.
- Open Package Manager window (Window | Package Manager)
- Click + button on the upper-left of a window, and select Add package from git URL...
- Enter the following URL and click Add button
https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity
- Click on
Manage NuGet Packages
from theNuGet
menu in the Unity Editor.
- Search for
Aptos
and install the package. Make sure to turn onShow Prerelease
in the top left.
Godot
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
file in the root of your Godot project. - Add the following line to the
<ItemGroup>
section of the.csproj
file. If it doesn't exist, create it the<ItemGroup>
section.
<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>
<ItemGroup>
<PackageReference Include="Aptos" Version="0.0.1-beta" />
</ItemGroup>
</Project>
- You can now use the Aptos SDK in your Godot project.
using Aptos;
public partial class MyClass : Node
{
public override void _Ready()
{
var client = new AptosClient(Networks.Mainnet);
var ledgerInfo = await client.Block.GetLedgerInfo();
Console.WriteLine($"Ledger Block Height: {ledgerInfo.BlockHeight}");
}
}
Usage
Initialize an instance of the AptosClient
class to interact with the Aptos blockchain. You can use a pre-defined network configuration from the Networks
class.
// 1. Import the Aptos namespace
using Aptos;
// 2. Initialize the Aptos client
var config = new AptosConfig(Networks.Mainnet);
var client = new AptosClient(config);
// 3. Use the client to interact with the blockchain!
var ledgerInfo = await client.Block.GetLedgerInfo();
Sign and Submit Transactions
To sign and submit a transaction, you can build a payload using the AptosClient
and sign it with an Account
signer.
using Aptos;
// 1. Initialize the Aptos client
var config = new AptosConfig(Networks.Mainnet);
var client = new AptosClient(config);
// 2. Create a new account
var account = Account.Generate();
// 2. Create a transaction payload
var transaction = await client.Transaction.Build(
sender: account,
data: new GenerateEntryFunctionPayloadData(
function: "0x1::aptos_account::transfer_coins",
typeArguments: ["0x1::aptos_coin::AptosCoin"],
functionArguments: [account.Address, "100000"]
)
);
// 3. Sign and submit the transaction
var pendingTransaction = client.Transaction.SignAndSubmitTransaction(account, transaction);
// 4. (Optional) Wait for the transaction to be committed
var committedTransaction = await client.Transaction.WaitForTransaction(pendingTransaction);
Features
- Binary Canonical Serialization (BCS) encoding and decoding
- Ed25519, SingleKey, MultiKey, and Keyless signer support
- Utilities for transaction building, signing, and submission
- Abstractions over the Aptos Fullnode and Indexer APIs
Examples
Examples can be found in the Aptos.Examples
project. Run the examples by using the following command:
dotnet run --project ./Aptos.Examples --framework net8.0
This will prompt the follow console. You can select an example to run by entering the corresponding number or using the arrow keys to navigate the menu.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Aptos.Indexer (>= 0.0.2-beta)
- Aptos.Poseidon (>= 0.0.2-beta)
- BouncyCastle.Cryptography (>= 2.4.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.0.2)
- NBitcoin (>= 7.0.37)
- Newtonsoft.Json (>= 13.0.3)
- StrawberryShake (>= 13.9.11)
- StrawberryShake.Transport.Http (>= 13.9.11)
-
net6.0
- Aptos.Indexer (>= 0.0.2-beta)
- Aptos.Poseidon (>= 0.0.2-beta)
- BouncyCastle.Cryptography (>= 2.4.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.0.2)
- NBitcoin (>= 7.0.37)
- Newtonsoft.Json (>= 13.0.3)
- StrawberryShake (>= 13.9.11)
- StrawberryShake.Transport.Http (>= 13.9.11)
-
net7.0
- Aptos.Indexer (>= 0.0.2-beta)
- Aptos.Poseidon (>= 0.0.2-beta)
- BouncyCastle.Cryptography (>= 2.4.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.0.2)
- NBitcoin (>= 7.0.37)
- Newtonsoft.Json (>= 13.0.3)
- StrawberryShake (>= 13.9.11)
- StrawberryShake.Transport.Http (>= 13.9.11)
-
net8.0
- Aptos.Indexer (>= 0.0.2-beta)
- Aptos.Poseidon (>= 0.0.2-beta)
- BouncyCastle.Cryptography (>= 2.4.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.0.2)
- NBitcoin (>= 7.0.37)
- Newtonsoft.Json (>= 13.0.3)
- StrawberryShake (>= 13.9.11)
- StrawberryShake.Transport.Http (>= 13.9.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.12-beta | 51 | 10/22/2024 |
0.0.11-beta | 87 | 10/19/2024 |
0.0.10-beta | 74 | 10/19/2024 |
0.0.9-beta | 90 | 10/9/2024 |
0.0.8-beta | 39 | 10/9/2024 |
0.0.7-beta | 58 | 10/2/2024 |
0.0.6-beta | 51 | 10/1/2024 |
0.0.5-beta | 48 | 9/30/2024 |
0.0.4-beta | 41 | 9/28/2024 |
0.0.3-beta | 45 | 9/27/2024 |
0.0.2-beta | 43 | 9/27/2024 |