Skip to content

Rust SDK - Examples

For sample code which explains the core concepts of how to use the SDK, see:

Below are additional resources which may be more suited for your individual use case.

The examples folder in the SDK repo has many code snippets you can customize to your needs.

ExampleDescription
transfer.rsBasic APT transfer between accounts
view_function.rsRead-only view function calls
simulation.rsSimulate transactions before submission
sponsored_transaction.rsFee payer (sponsored) transactions
multi_agent.rsMulti-signer transactions
account_management.rsAccount creation, mnemonics, and key types
indexer_queries.rsQuery the Aptos indexer via GraphQL
fungible_asset_transfer.rsTransfer a fungible asset
orderless_transaction.rsOrderless (nonce-based) transactions

To run one of the example scripts:

  1. Clone the repository.

    Terminal window
    git clone https://github.com/aptos-labs/aptos-rust-sdk.git
    cd aptos-rust-sdk
  2. Run an example with the features it needs.

    Terminal window
    cargo run -p aptos-sdk --example transfer --features "ed25519,faucet"