logoAcademy

Initial Token Allocation

Learn about the initial token allocation and configure in your EVM blockchain.

Background

Alloc defines the initial balances of addresses at the time of the chain creation. This should be changed accordingly for each chain.

If you don't provide any genesis allocation, you won't be able to interact with your new chain, since all transactions require a fee to be paid from the sender's balance. If there is no initial allocation, there are no funds to pay for any transactions

Format

The alloc field expects key-value pairs. Keys of each entry must be a valid address. The balance field in the value can be either a hexadecimal or number to indicate initial balance of the address.

{
  "config": {
    // ...
  },
  "alloc": {
    "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
      "balance": "0x295BE96E64066972000000"
    }
  },
  // ...
}

The keys in the allocation are hex addresses without the canonical 0x prefix. The balances are denominated in Wei (10^18 Wei = 1 Whole Unit of the native token of the chain) and expressed as hex strings with the canonical 0x prefix. You can use this converter to translate between decimal and hex numbers: RapidTables Number to HEX

The default configuration for testing purposes contains configures plenty of tokens to a the address 8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC. The private key for this address is: 56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027

Warning

Never use the address or the private key for anything but testing on a local test network. The private key is publicly known and any real funds transferred to the associated address are most likely going to be stolen.

Configure

Allocate tokens to two addresses:

  1. The well-known test address 8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
  2. Another test address you have created (do not use an address you use for real funds)

Example Code

{
  "config": {
    // ...
  },
  "alloc": {
    "8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
      "balance": "0x295BE96E64066972000000"
    },
    "<your_address>": {
      "balance": "0x295BE96E64066972000000"
    }
  },
  // ...
}
Updated:

On this page

Edit on Github