Skip to main content
This is the simplest possible SnarkVM example. It demonstrates account creation, key derivation, and basic operations with the Aleo blockchain.

Complete example

Step by step

Let’s break down what’s happening:
1

Import the prelude

The prelude provides all commonly used types. We also import thread_rng for random number generation.
2

Generate a private key

Creates a new cryptographically secure private key for the Testnet3 network. The private key is the root secret that controls the account.
3

Derive the view key

The view key is derived from the private key and can decrypt records without the ability to spend them.
4

Derive the address

The address is the public identifier for the account. It’s safe to share and is used to receive transactions.
5

Display the results

Print the account information. The address will start with aleo1 for all networks.

Expected output

When you run this example, you’ll see output like:
The private key is sensitive information. Never share it or commit it to version control.

Variations

Using different networks

You can use MainnetV0 or CanaryV0 instead of Testnet3:

Restoring from an existing private key

If you already have a private key string:

Next steps

Token transfer

Learn how to transfer credits between accounts

Working with accounts

Deep dive into account management