Avatar
0
monkey Enlightened
monkey Enlightened
Tạo một ethereum chain mới
  1. Chạy geth thông tường
  2. Tạo sẵn 2 tài khoản
  3. Tắt geth đi
  4. Tạo một thư mục mới ví dụ <code>/Users/monkey/geth</code>
  5. Tạo 1 genesis block trong thư mục <code>/Users/monkey/geth</code> kiểu:
    {
      "config": {
        "chainId": 15,
        "homesteadBlock": 0
      },
      "difficulty": "1",
      "gasLimit": "9999999",
      "nonce": "0xdeadbeefdeadbeef",
      "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "alloc": {
        "tài khoản đầu tiên bạn đã tạo": {
          "balance": "30000"
        },
        "tài khoản thứ 2 bạn đã tạo": {
          "balance": "50000"
        }
      }
    }
    
  1. Copy thư mục keystore từ thư mục của Ethereum vào thư mục <code>/Users/monkey/geth</code>
  2. Chạy lệnh khởi tạo:
    geth --datadir . init genesis.json
  1. Chạy lệnh để start local node:
    geth --syncmode fast --cache 512 --ipcpath ~/Library/Ethereum/geth.ipc --networkid 1234 --datadir . --http --http.api personal,eth,net,web3
  1. Thử test bằng cách gọi curl:
    curl --location --request GET 'http://localhost:8545/' 
    --header 'Content-Type: application/json' 
    --data-raw '{
    	"jsonrpc":"2.0",
    	"method":"eth_accounts",
    	"params":[],
    	"id":1
    }'
    
  1. Kiểm tra thử balance của 1 tài khoản:
    curl --location --request GET 'http://localhost:8545/' 
    --header 'Content-Type: application/json' 
    --data-raw '{
    	"jsonrpc":"2.0",
    	"method":"eth_getBalance",
    	"params":[
    		"địa chỉ tài khoản", 
    		"latest"
    	],
    	"id":1
    }'
    
tại đây
.
  • Answer
ethereum
Remain: 5
1 Answer
Avatar
monkey Enlightened
monkey Enlightened
Sharing
  • 0
  • Reply