Flow Emulator with Initial Accounts

149 views Asked by At

I'm trying to initialize the flow emulator with accounts. Here's my flow config file:

{
    "emulators": {
        "default": {
            "port": 3569,
            "serviceAccount": "delphai"
        }
    },
    "contracts": {
        "DelphaiUsers": {
            "source": "./cadence/contracts/DelphaiUsers.cdc",
            "aliases": {
                "emulator": "f8d6e0586b0a20c7"
            }
        },
        "FungibleToken": "./cadence/contracts/FungibleToken.cdc",
        "FlowToken": "./cadence/contracts/FlowToken.cdc",
        "FUSD": "./cadence/contracts/FUSD.cdc",
        "YesNoBetLibrary": "./cadence/contracts/YesNoBetLibrary.cdc",
        "YesNoResolverLibrary": "./cadence/contracts/YesNoResolverLibrary.cdc",
        "BetContractComposer": "./cadence/contracts/BetContractComposer.cdc"
    },
    "networks": {
        "emulator": "127.0.0.1:3569",
        "mainnet": "access.mainnet.nodes.onflow.org:9000",
        "testnet": "access.devnet.nodes.onflow.org:9000"
    },
    "accounts": {
        "delphai": {
            "address": "f8d6e0586b0a20c7",
            "key": "6a4c115ee4477dc14ea5dd6ba72739dde3d5f1e08313bfaebe08b6221e69d585"
        },
        "dan": {
            "address": "179b6b1cb6755e31",
            "key": "2a7cdee6cb802f70d1837342dd462563155b936f110495a904b96993d66ab6e1"
        },
        "tony": {
            "address": "f3fcd2c1a78f5eee",
            "key": "658f8dcf443f83e33a9ed5e33179da436fd2246efc114b897cc8013e331b60df"
        },
        "anil": {
            "address": "e03daebed8ca0615",
            "key": "2ce60e2df3ab73307dc25ec2dc271957a7c043564e8d586e09ab7575853b5103"
        }
    },
    "deployments": {
        "emulator": {
            "delphai": [
                "DelphaiUsers",
                "YesNoBetLibrary",
                "YesNoResolverLibrary",
                "BetContractComposer"
            ]
        }
    }
}

I run the emulator and flow project deploy --network=emulator and then try to get one of the accounts with flow accounts get 0x179b6b1cb6755e31 It can't find the address. I'm using flow cli version 0.33. Any ideas how to achieve this?

1

There are 1 answers

0
MaxStarka On BEST ANSWER

Unfortunately, at the time it's not gonna work this way. Emulator will not create new account, based on addresses provided in your flow.json file.

The reason for this is that addresses on Flow network are sequential and deterministically defined - contrary to Ethereum, where addresses are private key derivatives. So, even if Emulator can create new accounts for you, it won't be able to assign address, that you've specified.

If works for delphai account, cause that one is a service account.