First parameter must either be an object or the name of an existing class on Web3 on PHP

434 views Asked by At

I am creating an ERC Token selling website. When a user signs up on the website, there should be generated an eth wallet automatically for that user and to store in db. After that when ever the user purchase coins from our website, the coin amount should be transferred to the user's created eth wallet.

I've tried this code with web3 within laravel:

use Web3\Web3;
use Web3\Providers\HttpProvider;
use Web3\RequestManagers\HttpRequestManager;

public function createETHWallet()
{

$web3 = new Web3('http://localhost:8012');
$personal = $web3->personal;
$newAccount = '';

$personal->newAccount('123456', function ($err, $account) use (&$newAccount) {
    if ($err !== null) {
        echo 'Error: ' . $err->getMessage();
        return;
    }
    $newAccount = $account;
    echo 'New account: ' . $account . PHP_EOL;
});
}

But it is giving me an error, which is:

First parameter must either be an object or the name of an existing class

What is the issue?

Note: I am working on laravel app using web3 package.

0

There are 0 answers