furqansiddiqui / erc20-php

Interact with Ethereum ERC20 Tokens
MIT License
163 stars 96 forks source link

Transfer tokens not working #34

Closed gatepavel closed 1 year ago

gatepavel commented 3 years ago

old code from https://www.furqansiddiqui.com/transfer-erc20-token-from-one-account-to-another-using-php/ not worked - method personal() not found

matrix543 commented 3 years ago

$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

All guides online says you type it like this but the personal function is not in the class anymore and find a older version of this package looks pritty imposible

Farhadesfandiar commented 3 years ago

personal, in "$transaction = $geth->personal()->transaction($payer, $contract)" is exist in EthereumRPC. You may chek this issue (which wasn't actually an issue). So you need to also install EthereumRPC via composer require furqansiddiqui/ethereum-rpc

isszz commented 2 years ago

It should be replaced by ethereum-php, the previous method is no longer available. May I ask how the transfer using ethereum-php is done now?

isszz commented 2 years ago

Maybe so?

$eth = new \FurqanSiddiqui\Ethereum\Ethereum();
$erc20 = new \FurqanSiddiqui\Ethereum\ERC20\ERC20($eth);
$usdt = $erc20->token($contractAddress);

$payer = '0x...';
$payee = '0x...';
$amount = '0';
$data = $bnb->encodedTransferData($eth->getAccount($payee), $amount);

$tx = new \FurqanSiddiqui\Ethereum\Transactions\TxBuilder($eth);

$transaction = $tx->gas(new \FurqanSiddiqui\Ethereum\Math\WEIValue('1'), 70000)
    ->to($eth->getAccount($payer))
    ->value(new \FurqanSiddiqui\Ethereum\Math\WEIValue('0'))
    ->data($data);