aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-08-12 18:10:03 -0400
committerDeterminant <ted.sybil@gmail.com>2019-08-12 18:10:03 -0400
commitbc9539a1b60dc80946bc867681eb32ecae4f0d66 (patch)
tree0d691d52fecd2e3a52482d3420310e12aec95580 /examples
parentfd39e6b30af5d855dce23899394e6ef80a2c0a41 (diff)
make the basic demo work
Diffstat (limited to 'examples')
-rw-r--r--examples/payments/main.go35
1 files changed, 28 insertions, 7 deletions
diff --git a/examples/payments/main.go b/examples/payments/main.go
index d5d10b4..76306b0 100644
--- a/examples/payments/main.go
+++ b/examples/payments/main.go
@@ -1,7 +1,7 @@
package main
import (
- //"time"
+ "time"
"os"
"os/signal"
"syscall"
@@ -16,6 +16,7 @@ import (
"github.com/Determinant/coreth"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
+ "github.com/ethereum/go-ethereum/common"
)
func checkError(err error) {
@@ -25,14 +26,29 @@ func checkError(err error) {
func main() {
log.Root().SetHandler(log.StderrHandler)
config := eth.DefaultConfig
- chainConfig := params.MainnetChainConfig
+ chainConfig := &params.ChainConfig {
+ ChainID: big.NewInt(1),
+ HomesteadBlock: big.NewInt(0),
+ DAOForkBlock: big.NewInt(0),
+ DAOForkSupport: true,
+ EIP150Block: big.NewInt(0),
+ EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
+ EIP155Block: big.NewInt(0),
+ EIP158Block: big.NewInt(0),
+ ByzantiumBlock: big.NewInt(0),
+ ConstantinopleBlock: big.NewInt(0),
+ PetersburgBlock: big.NewInt(0),
+ IstanbulBlock: nil,
+ Ethash: nil,
+ }
genBalance := big.NewInt(1000000000000000000)
genKey, _ := coreth.NewKey(rand.Reader)
config.Genesis = &core.Genesis{
- Config: params.MainnetChainConfig,
+ Config: chainConfig,
Nonce: 0,
+ Number: 0,
ExtraData: hexutil.MustDecode("0x00"),
GasLimit: 100000000,
Difficulty: big.NewInt(0),
@@ -45,12 +61,17 @@ func main() {
gasLimit := 21000
gasPrice := big.NewInt(1000)
bob, err := coreth.NewKey(rand.Reader); checkError(err)
- tx := types.NewTransaction(nonce, bob.Address, value, uint64(gasLimit), gasPrice, nil)
- signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), genKey.PrivateKey); checkError(err)
- chain := coreth.NewETHChain(&config, chainConfig, nil)
+ chain := coreth.NewETHChain(&config, nil)
chain.Start()
- chain.AddLocalTxs([]*types.Transaction{signedTx})
+
+ for i := 0; i < 10; i++ {
+ tx := types.NewTransaction(nonce, bob.Address, value, uint64(gasLimit), gasPrice, nil)
+ signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), genKey.PrivateKey); checkError(err)
+ chain.AddLocalTxs([]*types.Transaction{signedTx})
+ time.Sleep(5000 * time.Millisecond)
+ nonce++
+ }
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)