furqansiddiqui / erc20-php

Interact with Ethereum ERC20 Tokens
MIT License
164 stars 97 forks source link

ERC20 token undefined type #36

Closed Farhadesfandiar closed 1 year ago

Farhadesfandiar commented 3 years ago

Hello @furqansiddiqui Thank you for your library which seems to be the best alternative for ERC20 token in PHP. I'm trying to run the following commands for sending a token:

use EthereumRPC\EthereumRPC;
use ERC20\ERC20;

$geth = new EthereumRPC('http://localhost', 8545);
$erc20 = new ERC20($geth);
$contract = "0x00000000000000000000000000"; // ERC20 contract address
$payer = "0x000000000000000000000"; // Sender's Ethereum account
$payee = "0x000000000000000000000"; // Recipient's Ethereum account
$amount = "0"; // Amount of tokens to transfer

$token = $erc20->token($contract);
$data= $token->encodedTransferData($payee, $amount);
$transaction = $geth->personal()->transaction($payer, $contract)  // from $payer to $contract address
->amount("0") // Amount should be ZERO
->data($data); // Our encoded ERC20 token transfer data from previous step
$txId = $transaction->send("$privatekey");
echo $txId;

but I face an error in this line:

$erc20 = new ERC20($geth);

which ERC20 is not defined!!! While I already installed the following libraries:

"furqansiddiqui/ethereum-rpc": "dev-master", "furqansiddiqui/http-client": "^0.4.5", "furqansiddiqui/erc20-php": "dev-master" PS: I checked to make sure I'm using the latest version of erc20-php and synchronization of all libraries.

Any help is appreciated