Go 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.
Code Snippets
Section titled “Code Snippets”The examples folder
in the SDK repository has many code snippets you can customize. These examples
are part of the SDK’s CI surface.
| Example | Description |
|---|---|
transfer_coin | Basic APT transfer between two accounts |
orderless_transaction | Orderless transfer with a replay-protection nonce |
sponsored_transaction | Fee-payer sponsored transaction |
multi_agent | Multi-agent transaction with two signers |
sending_concurrent_transactions | Concurrent submissions from one account |
fungible_asset | Fungible asset transfer |
onchain_multisig | On-chain multisig account flow |
offchain_multisig | Off-chain multisig signing |
script_transaction | Script payload construction |
alternative_signing | Custom / alternative signer |
external_signing | Sign with an external signer |
How to run examples
Section titled “How to run examples”To run one of the example scripts:
-
Clone the repository.
Terminal window git clone https://github.com/aptos-labs/aptos-go-sdk.gitcd aptos-go-sdk -
Run an example from the repository root. Go downloads module dependencies automatically.
Terminal window go run examples/transfer_coin/main.go
The SDK requires Go 1.25+.
Helpful Reference Code
Section titled “Helpful Reference Code”- Integration tests - Broader flows that use the SDK against a live network.
- Package tests -
*_test.gofiles next to the implementation. - SDK source code - This has in-line comments explaining what each function does.
- SDK reference docs - These are another way to view the in-line documentation with built-in search.