-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5364e4
commit 56e5a42
Showing
14 changed files
with
877 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
title: ".NET SDK " | ||
--- | ||
|
||
import { Card, Cards } from "@components/index"; | ||
import { Callout } from "nextra/components"; | ||
|
||
<Callout type="warning" emoji="❗"> | ||
This SDK is currently in beta. Please report any issues you encounter by | ||
creating an issue in the | ||
[aptos-labs/aptos-dotnet-sdk](https://github.com/aptos-labs/aptos-dotnet-sdk) | ||
repository. | ||
</Callout> | ||
|
||
# Aptos .NET SDK (Beta) | ||
|
||
Integrate Aptos web3 capabilities within your .NET applications. The goal of this SDK is to provide a set of tools | ||
for developers to build multi-platform applications across compatible game engines and platforms. | ||
|
||
**Supported 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 | ||
- Aptos Names (ANS) support for resolution and lookup | ||
|
||
## Installation | ||
|
||
The .NET SDK is available on [NuGet](https://www.nuget.org/packages/Aptos). | ||
|
||
You can install the .NET SDK using the following command: | ||
|
||
```bash | ||
dotnet add package Aptos | ||
``` | ||
|
||
## Gaming Integrations | ||
|
||
Begin using the Aptos .NET SDK in your game engine of choice. | ||
|
||
<Cards className="xl:grid-cols-2"> | ||
<Card href="./dotnet-sdk/godot-integration" className="flex flex-row gap-4"> | ||
<Card.Image src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Godot_icon.svg/2048px-Godot_icon.svg.png" /> | ||
<div className="flex flex-col gap-2"> | ||
<Card.Title>Godot Integration</Card.Title> | ||
<Card.Description> | ||
Begin integrating into Godot projects. | ||
</Card.Description> | ||
</div> | ||
</Card> | ||
<Card href="./dotnet-sdk/unity-integration" className="flex flex-row gap-4"> | ||
<Card.Image src="https://cdn-icons-png.freepik.com/512/5969/5969346.png" /> | ||
<div className="flex flex-col gap-2"> | ||
<Card.Title>Unity Integration</Card.Title> | ||
<Card.Description> | ||
Begin integrating into Unity projects. | ||
</Card.Description> | ||
</div> | ||
</Card> | ||
</Cards> | ||
|
||
### Compatibility | ||
|
||
| .NET Version | Supported | Target Game Engines | | ||
| ----------------- | --------- | ------------------- | | ||
| .NET Standard 2.1 | ✅ | Unity | | ||
| .NET 6.0 | ✅ | Godot | | ||
| .NET 7.0 | ✅ | Godot (Android) | | ||
| .NET 8.0 | ✅ | Godot (iOS) | | ||
|
||
## Resources | ||
|
||
<Cards className="xl:grid-cols-2"> | ||
<Card | ||
href="./dotnet-sdk/getting-started" | ||
className="col-span-2 flex flex-row gap-4" | ||
> | ||
<div className="flex flex-col gap-2"> | ||
<Card.Title>Getting Started</Card.Title> | ||
<Card.Description> | ||
Begin developing using the Aptos .NET SDK. | ||
</Card.Description> | ||
</div> | ||
</Card> | ||
</Cards> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default { | ||
"getting-started": { | ||
title: "Getting Started", | ||
}, | ||
"unity-integration": { | ||
title: "Unity Integration", | ||
}, | ||
"godot-integration": { | ||
title: "Godot Integration", | ||
}, | ||
accounts: { | ||
title: "Accounts", | ||
}, | ||
transactions: { | ||
title: "Transactions", | ||
}, | ||
}; |
5 changes: 5 additions & 0 deletions
5
apps/nextra/pages/en/build/sdks/dotnet-sdk/accounts/_meta.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
ed25519: { | ||
title: "Ed25519 Accounts", | ||
}, | ||
}; |
52 changes: 52 additions & 0 deletions
52
apps/nextra/pages/en/build/sdks/dotnet-sdk/accounts/ed25519.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: "Ed25519 Accounts" | ||
--- | ||
|
||
import { Steps, Callout } from "nextra/components"; | ||
import { Card, Cards } from "@components/index"; | ||
|
||
<Callout type="warning" emoji="❗"> | ||
This SDK is currently in beta. Please report any issues you encounter by | ||
creating an issue in the | ||
[aptos-labs/aptos-dotnet-sdk](https://github.com/aptos-labs/aptos-dotnet-sdk) | ||
repository. | ||
</Callout> | ||
|
||
# Ed25519 Accounts | ||
|
||
The Aptos .NET SDK provides a simple way to create and manage Ed25519 accounts. In this guide we | ||
will provide snippets of creating or importing existing accounts. | ||
|
||
## Creating Ed25519Accounts | ||
|
||
Ed25519Accounts are created to sign transactions and interact with the blockchain. | ||
|
||
### Using a Private Key | ||
|
||
To generate an account from a private key, you will need to create the `Ed25519PrivateKey` object and pass into into the | ||
`Ed25519Account` constructor. The private key can be given a `string` or `byte[]` representation. | ||
|
||
```csharp | ||
var privateKey = new Ed25519PrivateKey("0x1234...abcdef"); | ||
var account = new Ed25519Account(privateKey); | ||
``` | ||
|
||
### Using a Mneomonic Phrase | ||
|
||
To generate an account from a phrase, you can use `Ed25519Account.FromDerivationPath` and pass in the phrase and the derivation path. | ||
The derivation path that is typically used throughout the Aptos ecosystem is `m/44'/637'/0'/0'/0'`. | ||
|
||
```csharp | ||
var account = Ed25519Account.FromDerivationPath( | ||
"m/44'/637'/0'/0'/0'", | ||
"apple banana cat dog elephant fox ..." | ||
); | ||
``` | ||
|
||
### Generating a Random Account | ||
|
||
To create a random account, you can use the `Account.Generate()` method. | ||
|
||
```csharp | ||
var account = Account.Generate(); | ||
``` |
116 changes: 116 additions & 0 deletions
116
apps/nextra/pages/en/build/sdks/dotnet-sdk/getting-started.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
title: "Quickstart" | ||
--- | ||
|
||
import { Steps, Callout } from "nextra/components"; | ||
import { Card, Cards } from "@components/index"; | ||
|
||
<Callout type="warning" emoji="❗"> | ||
This SDK is currently in beta. Please report any issues you encounter by | ||
creating an issue in the | ||
[aptos-labs/aptos-dotnet-sdk](https://github.com/aptos-labs/aptos-dotnet-sdk) | ||
repository. | ||
</Callout> | ||
|
||
# Getting Started | ||
|
||
If you have not already installed the Aptos .NET SDK, follow one of the guides below to get started. | ||
|
||
<Cards className="xl:grid-cols-2"> | ||
<Card href="./godot-integration" className="flex flex-row gap-4"> | ||
<Card.Image src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Godot_icon.svg/2048px-Godot_icon.svg.png" /> | ||
<div className="flex flex-col gap-2"> | ||
<Card.Title>Godot Integration</Card.Title> | ||
<Card.Description> | ||
Integrate the Aptos .NET SDK with a Godot project. | ||
</Card.Description> | ||
</div> | ||
</Card> | ||
<Card href="./unity-integration" className="flex flex-row gap-4"> | ||
<Card.Image src="https://cdn-icons-png.freepik.com/512/5969/5969346.png" /> | ||
<div className="flex flex-col gap-2"> | ||
<Card.Title>Unity SDK</Card.Title> | ||
<Card.Description> | ||
Integrate the Aptos .NET SDK with a Unity project. | ||
</Card.Description> | ||
</div> | ||
</Card> | ||
</Cards> | ||
|
||
<Steps> | ||
|
||
### Set up your AptosClient | ||
|
||
Set up your Aptos client by adding the `Aptos` namespace and instantiating an `AptosClient`. You can use a predefined | ||
configuration from `Networks` or configuring your own. | ||
|
||
```csharp filename="Program.cs" {1-1, 7-8} | ||
using Aptos; | ||
|
||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var config = new AptosConfig(Aptos.Networks.Mainnet); | ||
var client = new AptosClient(config); | ||
} | ||
} | ||
``` | ||
|
||
### Query the Blockchain | ||
|
||
Now that you have the client setup, you can query the blockchain! | ||
|
||
```csharp filename="Program.cs" {10-11} | ||
using Aptos; | ||
|
||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var config = new AptosConfig(Aptos.Networks.Mainnet); | ||
var client = new AptosClient(config); | ||
|
||
var ledgerInfo = client.Block.GetLedgerInfo(); | ||
Console.WriteLine(ledgerInfo.BlockHeight); | ||
} | ||
} | ||
``` | ||
|
||
### Sign and Submit Transactions | ||
|
||
To interact with the blockchain, you will need to create a signer and build a transaction. | ||
|
||
```csharp filename="Program.cs" {10-11,13-21,23-24,26-27} | ||
using Aptos; | ||
|
||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var config = new AptosConfig(Aptos.Networks.Mainnet); | ||
var client = new AptosClient(config); | ||
|
||
// 1. Create a signer | ||
var signer = Account.Generate(); | ||
|
||
// 2. Build the transaction | ||
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); | ||
} | ||
} | ||
``` | ||
|
||
</Steps> |
Oops, something went wrong.