Quiero incorporar un javascript en php que enumere todas las cuentas y muestre los saldos de ellas. Este es mi script para eso:
<script language="javascript">
function checkAllBalances() {
var totalBal = 0;
for (var acctNum in eth.accounts) {
var acct = eth.accounts[acctNum];
var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
totalBal += parseFloat(acctBal);
console.log(" eth.accounts[" + acctNum + "]: \t" + acct + " \tbalance: " + acctBal + " ether");
alert("eth.accounts[" + acctNum + "]: ");
}
console.log(" Total balance: " + totalBal + " ether");
}</script>
Incorporé esto en php y lo llamé pero no lo está ejecutando correctamente. ¿Algunas ideas?
En realidad, es bastante simple hecho en PHP usando la biblioteca digitaldonkey/ethereum-php
$eth = new Ethereum('http://127.0.0.1:7545');
$balanceInWei = $eth->eth_getBalance(new EthD20($address), new EthBlockParam())->val();
$inEther = $eth->convertCurrency($balanceInWei);
Consulte: https://github.com/digitaldonkey/ethereum-php/blob/master/public/list-balance-example.php
kjrew2001
Nanolucas
kjrew2001
oxidado