5

Transactions contain the source account id, therefore you need an existing account to be able to create a new account and you also need funds in order to do anything.

So how was the first account created?

3 Answers 3

4

The genesis account is GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7, as Orbit Lens mentioned. It was created programmatically with the full initial network balance of XLM. You can see this by querying Horizon:

  1. The first transaction on the network is here: https://horizon.stellar.org/ledgers/3/transactions (it happened in ledger 3 - the first two ledgers are empty).
  2. You can take the envelope_xdr of that transaction and paste it into the Stellar laboratory to decode the base 64 XDR and inspect the transaction. It looks like this:
TransactionEnvelope
tx
sourceAccount: [publicKeyTypeEd25519]
ed25519: GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7
fee: 300
seqNum: 1
timeBounds: none
memo: [memoText]
text: hello world [hex: aGVsbG8gd29ybGQ=]
operations: Array[3]
[0]
sourceAccount: none
body: [createAccount]
createAccountOp
destination: [publicKeyTypeEd25519]
ed25519: GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB
startingBalance: 20.0000000 (raw: 200000000)
[1]
sourceAccount: none
body: [payment]
paymentOp
destination: [publicKeyTypeEd25519]
ed25519: GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB
asset: [assetTypeNative]
amount: 99999999959.9999700 (raw: 999999999599999700)
[2]
sourceAccount: none
body: [setOption]
setOptionsOp
inflationDest: none
clearFlags: none
setFlags: none
masterWeight: 0
lowThreshold: none
medThreshold: none
highThreshold: none
homeDomain: none
signer: none
  1. We see that the account GAAZ...CWN7 is the source. Three operations are performed:

    • Account GALP...MZTB is created
    • A payment of almost 100 billion lumens is made to this new account
    • The genesis account is locked (masterWeight: 0)
  2. This transfer needed to happen because the secret key of the genesis account (and from that, the account address itself) is derived from the network passphrase Public Global Stellar Network ; September 2015, which is public. Once the funds are moved to the new distribution account GALP...MZTB they are secure. The genesis account is locked by setting the master weight to 0, so no further operations can be performed from it.

  3. Because Stellar is open source, we can confirm that this is how genesis account creation works from the stellar-core source code:

    SecretKey skey = SecretKey::fromSeed(mApp.getNetworkID());

    LedgerTxn ltx(mApp.getLedgerTxnRoot(), false);
    ltx.loadHeader().current() = genesisLedger;

    LedgerEntry rootEntry;
    rootEntry.lastModifiedLedgerSeq = 1;
    rootEntry.data.type(ACCOUNT);
    auto& rootAccount = rootEntry.data.account();
    rootAccount.accountID = skey.getPublicKey();
    rootAccount.thresholds[0] = 1;
    rootAccount.balance = genesisLedger.totalCoins;
    ltx.create(rootEntry);

    CLOG(INFO, "Ledger") << "Established genesis ledger, closing";
  1. We also see from that file that the genesis account's balance is a constant, and is hardcoded (number is in stroops for precision).
    const int64_t LedgerManager::GENESIS_LEDGER_TOTAL_COINS = 1000000000000000000;
    ...
    LedgerManager::genesisLedger()
    {
        ...
        result.totalCoins = GENESIS_LEDGER_TOTAL_COINS;
        ...
    }

    ...
    rootAccount.balance = genesisLedger.totalCoins;
1
  • Great answer, thanks!
    – PiersyP
    Mar 21, 2020 at 0:17
5

The first account was created on the ledger 1 alongside with the Network initialization. It looks like GAAZ...CWN7 was the first Stellar account("genesis" account in blockchain terminology), with 100,000,000,000 XLM on it. Then funds were transferred to the distribution account GALP...MZTB, and the genesis account was locked.

Actually, the above statement is true only for the current version of the Network. Original Stellar network was launched in 2014, and then upgraded in 2015. So current ledger does not hold any records prior to September 2015.

All lumens owned by the Stellar Developers Foundation are now located on a few special accounts accordingly to SDF mandate.

1
  • Looking at ledger 3 we see the create account op where GAAZ...CWN7 creates GALP...MZTB, but in ledger 1 there are no transactions, so I still don't get how GAAZ...CWN7 was made?
    – PiersyP
    Jun 8, 2018 at 10:38
3

It's simple really. When you set up a new network you just pre-populate the SQL accounts table of the first network node with a single row for the genesis account containing the total initial supply of the native asset.

6
  • I can't see how that would work, since if the account exists only in the first network node's database then how would any other nodes be able to come to consensus on transactions issued from that account?
    – PiersyP
    Jun 8, 2018 at 10:21
  • 1
    When a node joins the network it implicitly agrees to the current state of the network and copies the existing ledger.
    – user1290
    Jun 8, 2018 at 10:48
  • That makes a lot of sense actually, thanks!
    – PiersyP
    Jun 8, 2018 at 11:07
  • @leondupe I realised that your explanation still doesn't add up. The current state of the network is the ledger, which is shared between nodes, but the internals of node's databases aside from that are not shared. So if the approach used is to pre-populate an account in the database of the first network node. Which means there is no account creation entry for it in the ledger, then the only node that can validate transactions for that account will be the first node. Even then if nodes try to validate the ledger as they sync they will not be able to validate transactions from the first account.
    – PiersyP
    Jun 11, 2018 at 15:06
  • The internals of a node's database is the ledger. See the definition of the term ledger in the context of stellar core. Each node has a copy of the ledger in the form of a set of database tables, this is the distributed database that is copied when a node joins the network. Pre-populate any of those tables and you bootstrap the network with that state.
    – user1290
    Jun 12, 2018 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.