Skip to main content

Account Creation

This document covers the transaction logic required to create accounts on the Flow blockchain. Read the accounts & keys documentation for an overview of the Flow account model.

Batch Account Creation

A single transaction can create multiple accounts by making multiple calls to the AuthAccount initializer.

danger

Due to current transaction limits, accounts should not be created in batches larger than 20 accounts.

The examples below emit the same flow.AccountCreated event as a normal account creation transaction. However, rather than emitting a single event, these transactions emit one event for each new account.

Check out this page to see how account creation transactions and events work in Go: Create an Account with the Go SDK.

Unique Key For Each Account


_10
transaction(publicKeys: [String]) {
_10
prepare(signer: AuthAccount) {
_10
for publicKey in publicKeys {
_10
let account = AuthAccount(payer: signer)
_10
account.addPublicKey(publicKey.decodeHex())
_10
}
_10
}
_10
}

Same Key For All Accounts


_11
transaction(publicKey: String, count: Int) {
_11
prepare(signer: AuthAccount) {
_11
var i = 0
_11
while i < count {
_11
let account = AuthAccount(payer: signer)
_11
account.addPublicKey(publicKey.decodeHex())
_11
_11
i = i + 1
_11
}
_11
}
_11
}