Ich möchte ein Javascript in PHP integrieren, das alle Konten auflistet und Salden für diese anzeigt. Das ist mein Skript dafür:
<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>
Ich habe dies in PHP integriert und aufgerufen, aber es wird nicht richtig ausgeführt. Irgendwelche Ideen?
Es ist eigentlich ziemlich einfach in PHP mit der Bibliothek 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);
Siehe: https://github.com/digitaldonkey/ethereum-php/blob/master/public/list-balance-example.php
kjrew2001
Nanolucas
kjrew2001
rostig