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.

Example Description
transfer.rs Basic APT transfer between accounts
view_function.rs Read-only view function calls
simulation.rs Simulate transactions before submission
sponsored_transaction.rs Fee payer (sponsored) transactions
multi_agent.rs Multi-signer transactions
orderless_transaction.rs Orderless (nonce-based) transactions
account_management.rs Account creation, mnemonics, and key types
multi_key_account.rs Mixed-scheme multi-key accounts
indexer_queries.rs Query the Aptos indexer via GraphQL
fungible_asset_transfer.rs Transfer a fungible asset
script_transaction.rs Script payload construction
deploy_module.rs Publish a Move package

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"