Created
July 9, 2020 09:40
-
-
Save MariusVanDerWijden/816f6c1f57bf5c19cb7191784a30802a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new SimulatedBackend with a default allocation | |
backend := backends.NewSimulatedBackend(core.DefaultGenesisBlock().Alloc, 9000000) | |
bal, err := backend.BalanceAt(ctx, common.HexToAddress("0x000"), nil) | |
// Create a meaningful allocation with a faucet secret key | |
faucetSK, err := crypto.GenerateKey() | |
faucetAddr := crypto.PubkeyToAddress(faucetSK.PublicKey) | |
addr := map[common.Address]core.GenesisAccount{ | |
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover | |
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256 | |
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD | |
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity | |
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp | |
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd | |
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul | |
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing | |
faucetAddr: {Balance: new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(9))}, | |
} | |
alloc := core.GenesisAlloc(addr) | |
backend := backends.NewSimulatedBackend(alloc, 9000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment