Skip to content

Commit

Permalink
Add the capability of passing the block number on eth-call
Browse files Browse the repository at this point in the history
  • Loading branch information
FDubath committed Sep 12, 2019
1 parent 2c64acc commit eabbce0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
} else if(isset($_REQUEST['ethCall'])){
header('Content-Type: application/json');
echo getEthCall($_REQUEST['ethCall'],$gethRPC);
}else if(isset($_REQUEST['ethCallAt']) && isset($_REQUEST['blockNb'])){
header('Content-Type: application/json');
echo getEthCallAt($_REQUEST['ethCallAt'],$_REQUEST['blockNb'],$gethRPC);
} else if(isset($_REQUEST['hash'])){
header('Content-Type: application/json');
echo getTransaction($_REQUEST['hash'],$gethRPC);
Expand Down Expand Up @@ -85,6 +88,22 @@ function getEthCall($txobj, $gethRPC){
}
return json_encode($data);
}


function getEthCallAt($txobj, $blockNb, $gethRPC){
$data = getDefaultResponse();
try {
$data['data'] = getRPCResponse($gethRPC->eth_call($txobj,
$blockNb));
}
catch (exception $e) {
$data['error'] = true;
$data['msg'] = $e->getMessage();
}
return json_encode($data);
}


function getTransactionData($addr, $gethRPC){
$data = getDefaultResponse();
try {
Expand Down

0 comments on commit eabbce0

Please sign in to comment.