aboutsummaryrefslogtreecommitdiff
path: root/examples/counter
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-08-30 08:02:51 -0400
committerDeterminant <[email protected]>2019-08-30 08:02:51 -0400
commitbf3776a5d5475f9ee35820099debfc49d71ea10c (patch)
tree530e8a2f804f8942d676c1a9362a1fcea612a692 /examples/counter
parent8c4e5b732d9584ecf9e77a4d93a987adb333d61a (diff)
...
Diffstat (limited to 'examples/counter')
-rw-r--r--examples/counter/main.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/examples/counter/main.go b/examples/counter/main.go
index 221291a..724a1f7 100644
--- a/examples/counter/main.go
+++ b/examples/counter/main.go
@@ -3,14 +3,16 @@ package main
import (
"crypto/rand"
"encoding/hex"
+ "encoding/json"
"fmt"
"github.com/ava-labs/coreth"
"github.com/ava-labs/coreth/eth"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/common/compiler"
- "github.com/ava-labs/go-ethereum/common/hexutil"
+ //"github.com/ava-labs/go-ethereum/common/hexutil"
"github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/types"
+ "github.com/ava-labs/go-ethereum/crypto"
"github.com/ava-labs/go-ethereum/log"
"github.com/ava-labs/go-ethereum/params"
"go/build"
@@ -48,18 +50,25 @@ func main() {
}
// configure the genesis block
- genBalance := big.NewInt(100000000000000000)
+ //genBalance := big.NewInt(100000000000000000)
genKey, _ := coreth.NewKey(rand.Reader)
- config.Genesis = &core.Genesis{
- Config: chainConfig,
- Nonce: 0,
- Number: 0,
- ExtraData: hexutil.MustDecode("0x00"),
- GasLimit: 100000000,
- Difficulty: big.NewInt(0),
- Alloc: core.GenesisAlloc{genKey.Address: {Balance: genBalance}},
- }
+ g := new(core.Genesis)
+ b := `{"config":{"chainId":1,"homesteadBlock":0,"daoForkBlock":0,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0},"nonce":"0x0","timestamp":"0x0","extraData":"0x00","gasLimit":"0x5f5e100","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","coinbase":"0x0000000000000000000000000000000000000000","alloc":{"751a0b96e1042bee789452ecb20253fba40dbe85":{"balance":"0x16345785d8a0000"}},"number":"0x0","gasUsed":"0x0","parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"}`
+ k := "0xabd71b35d559563fea757f0f5edbde286fb8c043105b15abb7cd57189306d7d1"
+ err := json.Unmarshal([]byte(b), g)
+ config.Genesis = g
+ hk, _ := crypto.HexToECDSA(k[2:])
+ genKey = coreth.NewKeyFromECDSA(hk)
+ //config.Genesis = &core.Genesis{
+ // Config: chainConfig,
+ // Nonce: 0,
+ // Number: 0,
+ // ExtraData: hexutil.MustDecode("0x00"),
+ // GasLimit: 100000000,
+ // Difficulty: big.NewInt(0),
+ // Alloc: core.GenesisAlloc{genKey.Address: {Balance: genBalance}},
+ //}
// grab the control of block generation and disable auto uncle
config.Miner.ManualMining = true
@@ -84,6 +93,7 @@ func main() {
blockCount := 0
chain := coreth.NewETHChain(&config, nil)
+ log.Info(chain.GetGenesisBlock().Hash().Hex())
firstBlock := false
var contractAddr common.Address
postGen := func(block *types.Block) bool {