- 在專案根目錄下執行:
composer install
-
在專案根目錄下執行:
cp .env.example .env -
編輯 .env
vi .env -
加入以下內容:
ETH_HOST='http://localhost'
ETH_PORT=8545
-
先在本機環境建一個新的資料庫「lottery」,相關設定則編輯 .env 內容的 DB_ 開頭屬性
-
在專案根目錄下執行:
php artisan migrate
-
Ganache 下載連結:
https://truffleframework.com/ganache -
安裝完啟動後本機就會預設有一條私鏈:
http://127.0.0.1:8545
- 執行以下指令:
npm install -g truffle
- 在 Laravel 專案根目錄下執行:
cd truffle
truffle compile
truffle migrate --reset
- 調整 app/Http/Controllers/LotteryController.php 中的「呼叫者錢包位址」與「被呼叫的合約或錢包位址」
- 調整 app/Http/Controllers/HomeController.php 中的「被呼叫的合約或錢包位址」
-
在 Laravel 專案根目錄下執行:
php artisan serve -
玩家連結:
http://127.0.0.1:8000
先註冊後下注
-
Truffle 用法
https://truffleframework.com/docs -
以太坊 RPC API 文件
https://github.com/ethereum/wiki/wiki/JSON-RPC -
Ethereum Package for Laravel
https://github.com/jcsofts/laravel-ethereum/blob/master/README.md