Skip to content
On this page

Pre-minted tokens โ€‹

The FA2 base classes accept an initial list of token metadata (or a single value for FA2SingleAsset) and an initial ledger. This gives you the ability to have pre-mint tokens in the contract storage at origination time.

See base classes for more info about the ledger value.

Examples โ€‹

Fa2Nft โ€‹

python
alice = sp.test_account("Alice")
    tok0_md = make_metadata(name="Token Zero", decimals=1, symbol="Tok0")
    tok1_md = make_metadata(name="Token One", decimals=1, symbol="Tok1")
    tok2_md = make_metadata(name="Token Two", decimals=1, symbol="Tok2")
    ExampleFa2Nft(
        metadata = sp.utils.metadata_of_url("http://example.com"),
        token_metadata = [tok0_md, tok1_md, tok2_md]
        ledger = {0: alice.address, 1: alice.address, 2: alice.address}
    )

Fa2Fungible โ€‹

python
alice = sp.test_account("Alice")
    tok0_md = make_metadata(name="Token Zero", decimals=1, symbol="Tok0")
    tok1_md = make_metadata(name="Token One", decimals=1, symbol="Tok1")
    tok2_md = make_metadata(name="Token Two", decimals=1, symbol="Tok2")
    ExampleFa2Fungible(
        metadata = sp.utils.metadata_of_url("http://example.com"),
        token_metadata = [tok0_md, tok1_md, tok2_md]
        ledger = {
            (alice.address, 0): 42,
            (alice.address, 1): 42,
            (alice.address, 2): 42,
        }
    )

Fa2SingleAsset โ€‹

python
alice = sp.test_account("Alice")
    tok0_md = make_metadata(name="Token Zero", decimals=1, symbol="Tok0")
    ExampleFa2SingleAsset(
        metadata = sp.utils.metadata_of_url("http://example.com"),
        token_metadata = tok0_md
        ledger = {alice.address: 42}
    )