Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mofalabs/aptos

A cross-platform Aptos SDK for Mobile, Web and Desktop
https://github.com/mofalabs/aptos

Last synced: 3 months ago
JSON representation

A cross-platform Aptos SDK for Mobile, Web and Desktop

Awesome Lists containing this project

README

        

Aptos Dart SDK
-

[![Pub](https://img.shields.io/badge/pub-v0.0.5-blue)](https://pub.dev/packages/aptos)

Installation
-

```
dependencies:
aptos: ^0.0.5
```

Usage
-

```dart
// Generate Aptos Account
final mnemonics = AptosAccount.generateMnemonic();
final sender = AptosAccount.generateAccount(mnemonics);
final receiver = AptosAccount();

// AptosClient connect with Aptos Node
final aptosClient = AptosClient(Constants.devnetAPI, enableDebugLog: true);

// Check and fund account
final amount = BigInt.from(10000000);
bool isExists = await aptosClient.accountExist(sender.address);
if (!isExists) {
final faucetClient = FaucetClient.fromClient(Constants.faucetDevAPI, aptosClient);
await faucetClient.fundAccount(sender.address, amount.toString());
await Future.delayed(const Duration(seconds: 2));
}

final coinClient = CoinClient(aptosClient);

// Check account balance
final balance = await coinClient.checkBalance(sender.address);
print(balance);

// Transfer Aptos Coin
final txHash = await coinClient.transfer(
sender,
receiver.address,
BigInt.from(10000),
createReceiverIfMissing: true);
print(txHash);
```