/AptosKit

A Comunity-Maintained Swift Aptos SDK

Primary LanguageCMIT LicenseMIT

AptosKit

Swift Platforms Swift Package Manager Swift

AptosKit is a community-maintained SDK for the Aptos Blockchain environment and REST API.

Features

  • Generate new wallets.
  • Create new accounts using the ED25519 Key Standard.
  • Simulate and submit transaction.
  • Create new collections.
  • Create new tokens.
  • Check account information (Token and APT balances, submitted contracts, etc).
  • Import previously used wallets using BIP-39 and BIP-32 Mnemonic seeds or an ED25519 private key.
  • Compatibility with main, dev, and test networks.
  • Comprehensive Unit and Integration Test coverage.
  • Swift Concurrency Support back to iOS 13, macOS 10.15, tvOS 13, and watchOS 6.
  • Complete documentation of AptosKit.
  • Implement Token REST Client.

ToDo

  • Token REST Client Example.
  • Implement enum object to switch between development, test, and main networks.

Requirements

Platform Minimum Swift Version Installation Status
iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ 5.5 Swift Package Manager Fully Tested
VisionOS 1.0 5.8 Swift Package Manager Untested

Installation

Swift Package Manager

The Swift Package Manager allows for developers to easily integrate packages into their Xcode projects and packages; and is also fully integrated into the swift compiler.

SPM Through XCode Project

  • File > Swift Packages > Add Package Dependency
  • Add https://github.com/opendive/AptosKit.git
  • Select "Up to next Major" with "1.2"

SPM Through Xcode Package

Once you have your Swift package set up, add the Git link within the dependencies value of your Package.swift file.

dependencies: [
    .package(url: "https://github.com/opendive/AptosKit.git", .upToNextMajor(from: "1.2"))
]

Using AptosKit

AptosKit is designed to be fully flexible for any project environment, and can easily be integrated into any projects using Swift 5.5 or later. The main method of utilizing AptosKit is to initialize a Wallet object using a Mnemonic, and a RestClient object:

import AptosKit

do {
    let mnemo = Mnemonic(wordcount: 12, wordlist: Wordlists.english)
    let wallet = try Wallet(mnemonic: mnemo)
    let restClient = try await RestClient(baseUrl: "https://fullnode.devnet.aptoslabs.com/v1")
} catch {
    print("ERROR - \(error)")
}

From there, it's as easy as calling one of the provided function members. The code below demonstrates how to airdrop 1 (one) APT token to the previously generated account:

    // ...
    let faucetClient = FaucetClient(baseUrl: "https://faucet.devnet.aptoslabs.com", restClient: restClient)
    try await faucetClient.fundAccount(wallet.account.address().description, 100_000_000)
    // ...

Development And Testing

We welcome anyone to contribute to the project through posting issues, if they encounter any bugs / glitches while using AptosKit; and as well with creating pull issues that add any additional features to AptosKit.

Next Steps

  • We will also focus on implementing a MultiED25519Authenticator for use with authenticating more than one ED25519 transaction at a time in a single call.

Credits

I would like to thank the Aptos Foundation for providing both the REST API and the blockchain implementation. Without them, this project would cease to be.

License

AptosKit is released under the MIT license, and any use of Aptos's REST endpoint will be under the Apache 2.0 License set by them.