- tạo file genesis.json
{ "config": { "chainId": 15, "homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0, "constantinopleBlock": 0 }, "difficulty": "400000", "gasLimit": "2100000", "alloc": {} }
- khởi tạo blockchain: <code>geth --datadir . init genesis.json</code>
- khởi động node <code>geth --syncmode fast --allow-insecure-unlock --cache 512 --ipcpath ~/Library/Ethereum/geth.ipc --networkid 1234 --datadir . --http --http.api "personal,eth,net,web3,miner" --http.corsdomain "*" --nodiscover</code>
- tạo account đầu tiên: <code>geth --datadir . account new</code>
- khởi động geth console: <code>geth attach http://localhost:8545/</code>
- 1 chạy lệnh để kiểm tra balance: <code>eth.getBalance(eth.accounts[0])</code>
- 2 chạy lệnh để unlock account: <code>personal.unlockAccount(eth.accounts[0])</code>
- 3 chạy lệnh để set ethbase: <code>miner.setEtherbase(eth.accounts[0])</code>
- 4 start miner: <code>miner.start()</code>
- tạo thư mục truffle: <code>mkdir truffle</code>
- <code>cd truffle</code>
- khởi tạo module, chạy lệnh: <code>truffle init</code>. Kết quả chúng ta có thự mục với cấu trúc:

- Cập nhật file <code>Migrations.sol</code>
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Migrations { string public message; uint public last_completed_migration; function Hello() public{ message = "Hello World!"; } function setCompleted(uint completed) public{ last_completed_migration = completed; } }
- Cập nhât file <code>truffle-config.js</code>
module.exports = { networks: { development: { host: "localhost", port: 8545, network_id: "*", gas: 1192085, from: "0x3c31b4b9d6c24bad29498f99aaa6914231362c7f" } } };
- Chạy lệnh: <pre>truffle compile</pre>
- Chạy lệnh: <pre>truffle migrate</pre>