이더리움

이더스캔 제작4 (개인별 잔액조회)

iesay 2019. 10. 22. 15:47

const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));const toAddress = "0x7a0e3AB3c9626018850c06A099981F0B1f183D95";
const privateKey = "0xA209084D071D63F598EB5C3A1B315CE8BDFED7906FF6D071CDADAB34244AAA69";
/*
web3.eth.accounts.signTransaction({
              to: toAddress,
              value: "300000000000000000",
              chainId: 3,
              gas: 21000
          }, privateKey, function (err, result) {
                        if (err) {
                                          console.error(err);
                                          return;
                                      }
                        console.log('rawTransaction ${result.rawTransaction}');
                        web3.eth.sendSignedTransaction(result.rawTransaction).on('receipt', console.log);
                    });
*/
web3.eth.getBalance("0x7a0e3AB3c9626018850c06A099981F0B1f183D95", "latest", function(err, result) {
                 console.log(result);
}); 

 

 

root@a0521f460f7b:~/npm# nodejs 1.js
You can improve web3's peformance when running Node.js versions older than 10.5.0 by installing the (deprecated) scrypt package in your project
5886845086420000000