'2018/11/26'에 해당되는 글 2건

입금

 

리눅스 버전 : ubuntu-18.04.1-desktop-amd64.iso 

 

입출금은 web3.js에서 개인키가지고 공개키 뽑고 이것저것 하면 되는거 같은데

개인별 송금조회는 @_@;;???

 

저번에도 한번 실패 했던거다.

 

블록체인 프로그래밍에서 가장 큰 문제점은 이론을 공부해야 된다.

이론이 뒷받침 되지 않고서는 절대 코딩 진도가 안나간다.

 

공개키도 개인키에서 뽑아내어서 사용하고

노드에서 검증도 개인키로 트랜잭션서명하고 공개키도 같이 보내는 형태다.

 

이런 이론을 공부하지 못하면 절대 코딩 진도가 안나간다.

 

그래서 일반 프로그래머들이 블록체인을 어려워할수도 있다.

 

npm install web3

apt-get install git

node

설치 완료

 

내일은 꼭 성공시킨다.

Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));
const toAddress = "0x7a0e3AB3c9626018850c06A099981F0B1f183D95";
const privateKey = "A209084D071D63F598EB5C3A1B315CE8BDFED7906FF6D071CDADAB34244AAA69";
web3.eth.accounts.signTransaction({
      to: toAddress,
      value: "100000000",
      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);
  });  

 

 

 

var Web3 = require("web3")
var web3 = new Web3("https://ropsten.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537")
var privateKey = "0xA209084D071D63F598EB5C3A1B315CE8BDFED7906FF6D071CDADAB34244AAA69"

var tx = {
    from: '0xFf0797D06e8F9897B1D5066C10D9497Ed7054A47',
    to: '0x7a0e3AB3c9626018850c06A099981F0B1f183D95',
    value: '1000000000',
    gas: 2000000,
    gasPrice: '234567897654321',
    nonce: 0,
    chainId: 3
}

var signed = web3.eth.accounts.signTransaction(tx, privateKey).then(console.log)
web3.eth.sendSignedTransaction(signed.rawTransaction)

{ messageHash: '0xf5845092cc8c2a842e58ec09c1d67faff14e9cfd8fde43291c9dba8174460507',
  v: '0x2a',
  r: '0x26a57ca1e79008a42e14605c8924618b9b3e4971f0c94d6bd8bb67ce49f1da1f',
  s: '0x1dc9cf69f088941767858934ffdec7e16c458ae4175c6343977647767d220f38',
  rawTransaction: '0xf86a8086d55698372431831e8480947a0e3ab3c9626018850c06a099981f0b1f183d95843b9aca00802aa026a57ca1e79008a42e14605c8924618b9b3e4971f0c94d6bd8bb67ce49f1da1fa01dc9cf69f088941767858934ffdec7e16c458ae4175c6343977647767d220f38' }

 

web3.eth.signTransaction  -> web3.eth.accounts.signTransaction

두함수는 서로 다름

 

 

 

Web3 = require("web3");

 

 

 

 

 Web3 = require("web3"); web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));

 

 

 

 

 

 

송금완료

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);
  });
 

 

'이더리움' 카테고리의 다른 글

geth 설치 이더리움노드  (0) 2018.11.29
이더리움 infura.io 주소  (0) 2018.11.28
이더스캔 제작3 (개인별 송금조회)  (0) 2018.11.28
이더스캔 제작2  (0) 2018.11.26
이더스캔 제작1  (0) 2018.11.23
블로그 이미지

iesay

,

이더스캔 제작2

이더리움 2018. 11. 26. 11:13

이더리움 테스트서버 ropsten기준으로 제작하였다.

파싱받아서 그걸 DB에 넣어서 input에서 조회하면 뿌려주면 된다.

말로는 졸라 쉽지

만들러면 ,,,,

 

web3.js도 git에서 가지고 오기 때문에 바로 소스 복붙해서 붙어 넣기 하면 사용 가능

위에 input은 어카운트 조회고

아래 textarea는 트렌젝션 조회내용을 담는거다.

 

 


<head>
<script type="text/javascript" src="https://github.com/ethereum/web3.js/blob/develop/dist/web3.js"></script>
<script type="text/javascript" src="https://github.com/MikeMcl/bignumber.js/blob/master/bignumber.min.js"></script>
<script type="text/javascript">
var result ="";
var web3 = new Web3();
var provider = new web3.providers.HttpProvider('https://ropsten.infura.io/');
web3.setProvider(provider);
function check_select() {
        var address = "0xFf0797D06e8F9897B1D5066C10D9497Ed7054A47";
        var tx="0xf7754179b1f735361ef63be6f940b9aaa163149ca05f9bb0f3791290701ec46f";
        var balance = web3.fromWei(web3.eth.getBalance(address), 'ether');
        document.getElementById("abc").value=balance;
        var receipt = web3.eth.getTransactionReceipt(tx);
        result = "tx:  "+tx+"\n\n";
        result+="blockHash:  "+receipt.blockHash+"\n\n";
        result+="blockNumver:  "+receipt.blockNumber+"\n\n";
        result+="cumulativeGasUsed: "+receipt.cumulativeGasUsed+"\n\n";
        result+="from: "+receipt.from+"\n\n";
        result+="gasUsed: "+receipt.gasUsed+"\n\n";
        result+="status:  "+receipt.status+"\n\n";
        result+="to:  "+receipt.to+"\n\n";
        result+="transactionHash:  "+receipt.transactionHash+"\n\n";
        result+="transactionIndex: "+receipt.transactionIndex+"\n\n";
        document.getElementById("output").value=result;
        console.log(receipt);
        }
</script>
</head>
<body>
Ropsten test ethereum Server
<br/>
<input type="button" name="" value="select" onclick="check_select();"/>
<br/>
balance account: <input type='text' id="abc" readonly/>
<br/>
<br/>
transaction check
<br/>
<textarea id="output" style="width:70%; height:70%" readonly/>
</body>
</html>
 

 

 

'이더리움' 카테고리의 다른 글

geth 설치 이더리움노드  (0) 2018.11.29
이더리움 infura.io 주소  (0) 2018.11.28
이더스캔 제작3 (개인별 송금조회)  (0) 2018.11.28
이더스캔 제작3 (입금)  (0) 2018.11.26
이더스캔 제작1  (0) 2018.11.23
블로그 이미지

iesay

,