- Chạy geth thông tường
- Tạo sẵn 2 tài khoản
- Tắt geth đi
- Tạo một thư mục mới ví dụ
/Users/monkey/geth - Tạo 1 genesis block trong thư mục
/Users/monkey/gethkiể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"
}
}
}
- Copy thư mục keystore từ thư mục của Ethereum vào thư mục
/Users/monkey/geth
- Chạy lệnh khởi tạo:
geth --datadir . init genesis.json
- 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
- 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
}'
- 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
}'
Tham khảo thêm tại đây.