furqansiddiqui / erc20-php

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

Composer dont work on php 8 #35

Closed matrix543 closed 1 year ago

matrix543 commented 3 years ago

Composer fail if you run php 8.05

matrix543 commented 3 years ago

Problem 1

hbedek commented 3 years ago

Same here for me ...

aliqasemzadeh commented 1 year ago

I have this problem too. You can install it with --ignore-platform-reqs

matrix543 commented 1 year ago

I did a solution where I fork the repo edited it to work with php8 uploaded it so I could install the package with composer from my own repo

matrix543 commented 1 year ago

composer require matrix543/erc20-php

aliqasemzadeh commented 1 year ago

@matrix543 How to get balance of token with this package? Can you give me example?

matrix543 commented 1 year ago

i did it in laravel so install wih composer v2

in your laravel controller

use EthereumRPC\EthereumRPC; use ERC20\ERC20;

public static function getbalance($address){
    $id = Auth::id();

    $geth = new EthereumRPC('127.0.0.1', '8545');
    $token_contract = <ETH token contract addr>

    $erc20 = new ERC20($geth);

    $token = $erc20->token($token_contract);
    $balance = $token->balanceOf($address);

    return $balance;

}
matrix543 commented 1 year ago

in composer json

"matrix543/erc20-php": "^0.1.4", "matrix543/ethereum-rpc": "^0.1.5",

aliqasemzadeh commented 1 year ago

Does it work with metamask open nodes?

matrix543 commented 1 year ago

it talks to a geth node that you run on your lokal pc or a vps you can connect metamask to a lokal geth node to

aliqasemzadeh commented 1 year ago

I want to use metamask RPCs to get balance of address in php without running full node.

matrix543 commented 1 year ago

it depends if metamask let you connect to an ip and port the php package will work otherwise you have to run geth with lightmode on a server so it dosent eat up your hard drive

geth --syncmode "light"