furqansiddiqui / erc20-php

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

encodedTransferData error #28

Closed develflowing closed 1 year ago

develflowing commented 3 years ago

$data = $token->encodedTransferData($payee, $amount);

` PHP Fatal error: Uncaught TypeError: Argument 1 passed to FurqanSiddiqui\Ethereum\ERC20\ERC20_Token::encodedTransferData() must be an instance of FurqanSiddiqui\Ethereum\Accounts\Account, string given, called in /getbalance.php on line 29 and defined in /vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php:193 Stack trace:

0 /getbalance.php(29): FurqanSiddiqui\Ethereum\ERC20\ERC20_Token->encodedTransferData()

1 {main}

thrown in /vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php on line 193 `

kaadon commented 3 years ago

$data = $token->encodedTransferData($eth->getAccount($payee), $amount);

develflowing commented 3 years ago

$data = $token->encodedTransferData($eth->getAccount($payee), $amount);

Thanks for Your reply, another problem:

require DIR . '/vendor/autoload.php';

$eth = new \FurqanSiddiqui\Ethereum\Ethereum(); $infura = new \FurqanSiddiqui\Ethereum\RPC\InfuraAPI($eth, "123", "321"); $infura->ignoreSSL(); // In case Infura.IO SSL errors

$erc20 = new \FurqanSiddiqui\Ethereum\ERC20\ERC20($eth); $erc20->useRPCClient($infura);

$usdt = $erc20->token("0xdac17f958d2ee523a2206206994597c13d831ec7"); $data = $usdt->encodedTransferData($eth->getAccount("0xdac17f958d2ee523a2206206994597c13d831ec7"), 1);

$transaction = $eth->personal()->transaction("0xdac17f958d2ee523a2206206994597c13d831ec7", "0xdac17f958d2ee523a2206206994597c13d831ec7") // from $payer to $contract address ->amount("0") // Amount should be ZERO ->data($data); // Our encoded ERC20 token transfer data from previous step

PHP Fatal error: Uncaught Error: Call to undefined method FurqanSiddiqui\Ethereum\Ethereum::personal() in /erc20-php/main.php:15

How can I sen transaction via Infura?

Thanks.

arnezt commented 3 years ago

I found the same issue.. I try to fresh install and I didn't find the Personal class anymore in the latest version... It stop on encodedTransferData() method in ERC20_Token class.. It just produced the encoded data to transfer but how to send. How to perform ERC20 transaction now?

atlaschiew commented 3 years ago

I found the same issue.. I try to fresh install and I didn't find the Personal class anymore in the latest version... It stop on encodedTransferData() method in ERC20_Token class.. It just produced the encoded data to transfer but how to send. How to perform ERC20 transaction now?

you may refer to here https://www.btcschools.net/ethereum/eth_erc20_tx.php, i also apply this repo in my work

arnezt commented 3 years ago

I found the same issue.. I try to fresh install and I didn't find the Personal class anymore in the latest version... It stop on encodedTransferData() method in ERC20_Token class.. It just produced the encoded data to transfer but how to send. How to perform ERC20 transaction now?

you may refer to here https://www.btcschools.net/ethereum/eth_erc20_tx.php, i also apply this repo in my work

Thank you buddy.. I'll try it.