web3p / web3.php

A php interface for interacting with the Ethereum blockchain and ecosystem. Native ABI parsing and smart contract interactions.
MIT License
1.15k stars 540 forks source link

Any documentation with common examples? #348

Open JTorresConsulta opened 3 months ago

JTorresConsulta commented 3 months ago

Hi ! Thanks for the library but It is a madness :/

Any documentation with common examples?

I am trying to get the Symbol of a ERC-20 like this:

$contract->at($contractAddress)->getData('symbol');

The return: 95d89b41 (the result would be Uni 2.6)

I am trying to convert from Utils::toString, utf_encode, utf_decode, pack.... nothing works

Thanks.

JTorresConsulta commented 3 months ago

This code solved it:


$contract->at($contractAddress)->call('symbol', function ($err, $result) {
  if ($err !== null) { return; } 
  echo 'The symbol: ' .  $result[0];
});
JTorresConsulta commented 3 months ago

Any way to getPastEvents with this library?

Thanks