Closed dformdotdk closed 6 years ago
If I try to install using composer I get this error:
composer require furqansiddiqui/erc20-php
Using version ^0.1.1 for furqansiddiqui/erc20-php
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for furqansiddiqui/erc20-php ^0.1.1 -> satisfiable by furqansiddiqui/erc20-php[0.1.1].
- furqansiddiqui/erc20-php 0.1.1 requires furqansiddiqui/ethereum-rpc dev-master -> satisfiable by furqansiddiqui/ethereum-rpc[dev-master] but these conflict with your requirements or minimum-stability.
Installation failed, deleting ./composer.json.
@dyvel try creating a composer.json file manually and putting the following content in it:
{ "minimum-stability": "dev", "require": { "furqansiddiqui/erc20-php": "dev-master", "kesar/ethereum-php": "dev-master" } }
After this, navigate to your directory in the terminal and enter composer install
For me it works this way.
Thanks that helped :-)
Installing using composer created a vendor folder with 7 subfolder, furqansiddiqui being one of them, and an autoload.php file. I included the autoload file, and it now connects to geth.
But I'm getting this error:
PHP Fatal error: Uncaught EthereumRPC\\Exception\\ConnectionException: Expected "application/json", got "text/plain; charset=utf-8" in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/EthereumRPC.php:141
Do you have an idea as to why I'm getting this error?
I'm starting geth with this command: geth --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --light
I understand this error. But not sure why you got it. You should try to send a request to geth using curl and checking the response. Maybe the connection isn't working. I'm starting Geth this way:
geth --syncmode "light" --rpc --rpcaddr IPADDRESS --rpcapi="db,eth,net,web3,personal,web3"
Here is an example curl request:
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be", "latest"],"id":3}' http://IPADDRESS:8545
Seems the script doesn't like a hostname - changed it to an ip. Closer to get it working now :-)
Running the php script now throws this error:
`PHP Fatal error: Uncaught ERC20\Exception\ERC20Exception: Failed to retrieve ERC20 token decimals/scale value in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php:101 Stack trace:
thrown in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php on line 101`
BTW, thanks for all your help @mrpetfreak
@dyvel happy to help you. Because of the error: Did you test your Geth manually via curl? What response do you get? I know, for example, if you started geth again you need to wait some minutes to have enough peers again.
@dyvel please give contract address so I can reproduce this issue
@furqansiddiqui I'm using the code below. The address is the one from your example - just trying to get it working, before I modify anything....
<?php
require('vendor/autoload.php');
use EthereumRPC\EthereumRPC;
use ERC20\ERC20;
$geth = new EthereumRPC('195.xxx.xxx.xxx', 8545);
$erc20 = new \ERC20\ERC20($geth);
$token = $erc20->token('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07');
var_dump($token->name());
var_dump($token->symbol());
var_dump($token->decimals());
?>
I just tried again - got a response now, but still see errors in my log file.
Tried a manuel call to Geth
Call: curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xd26114cd6EE289AccF82350c8d8487fedB8A0C07", "latest"],"id":3}' http://IPADDRESS:8545
Response: {"jsonrpc":"2.0","id":3,"result":"0x0"}
Using the code I posted in my comment above, the output was: string(8) "OMGToken" string(3) "OMG"
In my server log I see:
PHP Fatal error: Uncaught Error: Call to undefined function EthereumRPC\\bcadd() in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/BcMath.php:32
Stack trace:
#0 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/Contracts/ABI/DataTypes.php(119): EthereumRPC\\BcMath::HexDec('12')
#1 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/Contracts/ABI.php(182): EthereumRPC\\Contracts\\ABI\\DataTypes::Decode('uint', '12')
#2 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/Contracts/Contract.php(95): EthereumRPC\\Contracts\\ABI->decodeResponse('decimals', '000000000000000...')
#3 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php(98): EthereumRPC\\Contracts\\Contract->call('decimals')
#4 /home/DOMAIN/public_html/eth/test.php(18): ERC20\\ERC20_Token->decimals()
#5 {main}
thrown in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/BcMath.php on line 32
You need to have bcmath extension installed and enabled.
On ubuntu / debian based systems you may run:
sudo apt-get install php-bcmath
On Wed, Jun 13, 2018, 5:38 PM dyvel notifications@github.com wrote:
I just tried again - got a response now, but still see errors in my log file.
Tried a manuel call to Geth Call: curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xd26114cd6EE289AccF82350c8d8487fedB8A0C07", "latest"],"id":3}' http://IPADDRESS:8545 Response: {"jsonrpc":"2.0","id":3,"result":"0x0"}
Using the code I posted above, the output was: string(8) "OMGToken" string(3) "OMG"
In my server log I see:
PHP Fatal error: Uncaught Error: Call to undefined function EthereumRPC\bcadd() in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/BcMath.php:32 Stack trace:
0 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/Contracts/ABI/DataTypes.php(119): EthereumRPC\BcMath::HexDec('12')
1 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/Contracts/ABI.php(182): EthereumRPC\Contracts\ABI\DataTypes::Decode('uint', '12')
2 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/Contracts/Contract.php(95): EthereumRPC\Contracts\ABI->decodeResponse('decimals', '000000000000000...')
3 /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php(98): EthereumRPC\Contracts\Contract->call('decimals')
4 /home/DOMAIN/public_html/eth/test.php(18): ERC20\ERC20_Token->decimals()
5 {main}
thrown in /home/DOMAIN/public_html/eth/vendor/furqansiddiqui/ethereum-rpc/src/BcMath.php on line 32
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/furqansiddiqui/erc20-php/issues/3#issuecomment-396922377, or mute the thread https://github.com/notifications/unsubscribe-auth/AK9ABU6J94jVRD35B-c5fRkiHZrN4r1Iks5t8Qe-gaJpZM4Uk_2g .
@furqansiddiqui Bingo! - that did the trick - thank you so much! :-) 👍
Glad to help!
Hi @furqansiddiqui,
Thanks for your ERC20 Library. am using your library and getting the below error.
ERC20\Exception\ERC20Exception: Failed to retrieve ERC20 token decimals/scale value in file /var/www/html/tokendash/vendor/furqansiddiqui/erc20-php/src/ERC20_Token.php on line 101
Looking forward your suggestions/help to fix the issues.
Thanks
<?php require('vendor/autoload.php');
use EthereumRPC\EthereumRPC; use ERC20\ERC20;
$geth = new EthereumRPC('192.168.100.5', 8545); $erc20 = new \ERC20\ERC20($geth);
$token = $erc20->token('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07');
var_dump($token->name()); var_dump($token->symbol()); var_dump($token->decimals()); ?>
erespond@notebook:/opt/lampp/htdocs/coba3$ php coba3.php string(0) "" string(0) "" int(0)
Why i get that and on geth : INFO [10-23|03:28:23.847] New local node record seq=2 id=1938ba47425ce4be ip=127.0.0.1 udp=30303 tcp=30303 INFO [10-23|03:28:23.847] Started P2P networking self=enode://7b60a4d4bc471e31ba38a52ea01a053c7791a399f40fbaaf759890ee92772e1994ab8d65f2eb8a84137f906d4959f93a7347be8898193d6404159f5d525c2117@127.0.0.1:30303 INFO [10-23|03:28:23.847] IPC endpoint opened url=/home/erespond/.ethereum/geth.ipc INFO [10-23|03:28:23.848] HTTP endpoint opened url=http://192.168.100.5:8545 cors= vhosts=localhost
Hi
I'm really thankful for you, providing this package. I have installed Geth on a separate server.
I have created a folder where I've uploaded all erc20-php files together with the ethereal-rpc and http-client files. Then created an index.php file where I added this code:
However, I'm getting an error: PHP Fatal error: Uncaught Error: Class 'EthereumRPC'
Could you perhaps write a small guide to get started? That would be awesome.
Kind regards