Create a Keypair
Stellar uses public key cryptography to secure every transaction: each Stellar account has a keypair consisting of a public key and a secret key. The public key is always safe to share — other people need it to identify your account and verify that you authorized a transaction. It’s like an email address. The secret key, however, is private information that proves you own — and gives you access to — your account. It’s like a password, and you should never share it with anyone. Before creating an account, you need to generate your own keypair; we’ll learn how in the full example, below.Create an Account
A valid keypair alone does not make an account. To prevent unused entries from bloating the ledger, Stellar requires every account to hold a minimum balance of two base reserves before it actually exists (at the current base reserve of 0.5 XLM that works out to 1 XLM, but validators can change the base reserve — see the linked section for the current value). This is the ordinary, self-funded path shown throughout this tutorial. Alternatively, an account can be created with astartingBalance of 0 when another account sponsors its reserves (CAP-33 sponsored reserves): the sponsor carries the two base reserves on the new account’s behalf, so the account exists without holding the minimum balance itself. See the Sponsored Reserves guide for how to set this up.
On the test network you can ask Friendbot — a friendly funding service — to create and fund the account for you. In the SDK examples, below, you’ll see that we “discover” the Friendbot endpoint via the RPC’s getNetwork call, then issue a funding request.
On the public network, things are a little different. You’d acquire lumens from an exchange or have someone create or sponsor an account on your behalf. This is the purpose of the CreateAccount operation. We’ll see in the examples, later, that given a funded account, you can then create a child account on the network with a starting balance.
Fetch Balances
Once your accounts exist you can query their state. On Stellar, assets can be held in a handful of different forms:- your native balance is how much XLM you’re holding, which is associated directly to your account
- you can also establish trustlines to various assets to hold your balance; these can be acquired both by simple payment operations and smart contract interactions
- finally, you can hold custom smart contract tokens which are non-standard assets