Reputation: 509
I am using this PHP library https://github.com/web3p/web3.php to make the requests to smart contracts on Ethereum from a PHP server.
PHP return no error but nothing is showed.
Ths smart contract has transfers in the Gnosis blockchain (low fees to test ;) ). https://gnosisscan.io/tx/0xf628c8132d6f44610b67b81c6bd354c04c5ce7b4918e05b1bb566725966e40f0
Any idea why it doesn't work?
<?php
require 'web3php/vendor/autoload.php';
use Web3\Web3;
use Web3\Contract;
use Web3\Utils;
$contractAddress = '0xf628c8132d6f44610b67b81c6bd354c04c5ce7b4918e05b1bb566725966e40f0';
$fromBlock = '0x' . dechex(0);
$toBlock = 'latest';
$contract->at($contractAddress)->getEvents('Transfer',
[
'fromBlock' => $fromBlock,
'toBlock' => $toBlock
],
function ($err, $events) {
if ($err !== null) {
echo 'Error: ' . $err->getMessage();
return;
}
foreach ($events as $event) {
// Decodifica los datos del evento
$from = '0x' . substr($event['data'], 26, 40);
$to = '0x' . substr($event['data'], 90, 40);
$value = Utils::toBn('0x' . substr($event['data'], 130));
echo "From: $from\n";
echo "To: $to\n";
echo "Value: " . $value->toString() . "\n";
}
});
Upvotes: 0
Views: 106