<?php

use GuzzleHttp\Client;
use Illuminate\Support\Facades\Route;
use Web3\Providers\HttpProvider;
use Web3\Web3;

Route::get('/test-web3', function () {
    // $web3 = new Web3('https://mainnet.infura.io/v3/ceb4df0ad78242a492cd98e357099314');

    $web3 = new Web3('https://mainnet.infura.io/v3/ceb4df0ad78242a492cd98e357099314');
    $web3->eth->blockNumber(function ($err, $block) {
        if ($err !== null) {
            return response()->json(['error' => $err->getMessage()]);
        }
        return response()->json(['block_number' => $block]);
    });
});

Route::get('/', function () {
    return view('welcome');
});
