풀노드 구축

이더리움 2024. 3. 13. 10:38

https://github.com/eth-educators/eth-docker

 

GitHub - eth-educators/eth-docker: Docker automation for Ethereum nodes

Docker automation for Ethereum nodes. Contribute to eth-educators/eth-docker development by creating an account on GitHub.

github.com

./ethd install
./ethd config
./ethd up 

config 과정에서 execution, consensus 노드 원하시는 걸로 선택
모니털이 필요하면 grafana, prometheus 설정



피어 찾을때 레이턴시가 적은 피어들을 찾아서 수동으로 넣어줄수있어요 geth
그걸 자동화해두면 성능 향상에 좋습니다

 

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

EIP-1559 분석  (2) 2021.07.12
graphsq + mongodb  (0) 2021.06.08
스마트컨트렉 함수 접근 방법  (0) 2020.12.08
token 송금  (0) 2019.10.28
rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
블로그 이미지

iesay

,

EIP-1559 분석

이더리움 2021. 7. 12. 19:27

출처 : https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md

        https://github.com/ethers-io/ethers.js/issues/1610

       https://web3py.readthedocs.io/en/stable/web3.eth.html

       https://github.com/ethers-io/ethers.js

항목 AS_IS TO_BE
Gas - 사용자가 실시간 현 시세를 인지 해야됨


- 거래소의 출금지갑이 pending 발생시
  이후 모든 트랜젝션이 오류 장애 발생 요인


- 지갑 , Dapp 개발자 gas비 실시간
  조회 기능
- 수수료 예측 및 조회 확률이 이전 보다 높아짐

- Pending으로 인한 송금 실패는 현저히
  줄어 들것 임


- Dapp 더욱 더 활성화 될것으로 예상
채굴자 보상 -블록생성시 발생되는 이더리움과
  GAS 모두 채굴로 보상 받음
-단기적 보상이 줄어들어 이더리움 가격이
     상승이 동반 되지 않을시 채굴자 대거 이탈
     (이더리움 클래식, 제트캐쉬)


-전체 장비 중 일부만 운영 예상 (20% ~50%)
-
-장기적인 관점으로 트랜젝션이 늙어나고 소각량도 많아져 가격 상승하여 회귀 할것으로 예상
capacity - 블록사이즈(고정) : 12.5M
 
- 최초 가격이 현재 시세보다 높게 잡아
  사용자들이 지불 해야되는 비용이 증가


- 경쟁 방식 가장 높은 비용을 지불한
  사용자가 우선 전송
 
-블록사이즈(가변) :12.5 M  -> 25M
    네트워크 용량의 50%이상 사용시
    더 많은 데이터를 블록에 저장


- 이더리움 유통량이 점점 줄어들것으로 예상

 

 

 

기존 레거시 송금
https://ropsten.etherscan.io/tx/0xbc665337265e7d23f63ba50b2d2ba6db4b6e200c35c89b08cba7491996d9ef78

var Web3 = require("web3")
var web3 = new Web3("https://ropsten.infura.io/v3/API키")
var privateKey = "개인키"
const toAddress = "0x7a0e3AB3c9626018850c06A099981F0B1f183D95";
var tx = {
 to: toAddress,
 value: "300000000000000000",
 chainId: 3,
 gas: 21000
}

const app = async () => {
  try {
   var signed = await web3.eth.accounts.signTransaction(tx, privateKey);
   console.log('SIGN', web3.eth.sendSignedTransaction(signed.rawTransaction));
  }catch (error) { console.log('Task Failure',error);
 }
};
app();

 

 

 

 

EIP-1559 송금
https://ropsten.etherscan.io/tx/0x901cada97279cd77daf2e8202356d5a81eae0c918ab9bebe475eb1def7f213be

var Web3 = require("web3")
var web3 = new Web3("https://ropsten.infura.io/v3/API키")
var privateKey = 개인키
const toAddress = "0x07098B928D40E6Bd143EB9550FbBb5c2ca0Ec1E5";


var tx = {
 to: toAddress,
 value: "10000000000000000",
 chainId: 3,
 gasLimit: 21000,
 gasPrice:   10000,
 gasFeeCap:  10000,
 gasTipCap:  50000,
}


const app = async () => {
  try {
   var signed = await web3.eth.accounts.signTransaction(tx, privateKey);
   console.log('SIGN', web3.eth.sendSignedTransaction(signed.rawTransaction));

  }catch (error) { console.log('Task Failure',error);
 }
};
app();

Txn Type : 0 (Legacy) 로 보이는 부분은 아직 잘 모르곘다.

 

 

공식 문서로 정리를 하긴 할텐데 가장 짜증나던 부분이

같은 의미인데 여러가지 함수로 사용된 부분이다.

노드에서 sign트렌젝션에 대해 검증을 하면 결국 하나의 함수명으로 처리 될텐데

왜 이렇게 해깔리게 작성한지 모르겠다.

 

 

코드 npm 모듈 ethereumjs/tx

import Common from '@ethereumjs/common'
import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx'

const common = new Common({ chain: 'ropsten'hardfork: 'london' })

const txData = {
  "data": "0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x02625a00",
  "maxPriorityFeePerGas": "0x01",
  "maxFeePerGas": "0xff",
  "nonce": "0x00",
  "to": "0xcccccccccccccccccccccccccccccccccccccccc",
  "value": "0x0186a0",
  "v": "0x01",
  "r": "0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9",
  "s": "0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64",
  "chainId": "0x03",
  "accessList": [],
  "type": "0x02"
}

const tx = FeeMarketEIP1559Transaction.fromTxData(txData, { common })
console.log(tx);


 

 

실행 결과 

[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node ether.js`
FeeMarketEIP1559Transaction {
  activeCapabilities: [ 1559, 2718, 2930 ],
  DEFAULT_CHAIN: 'mainnet',
  DEFAULT_HARDFORK: 'london',
  _type: 2,
  nonce: <BN: 0>,
  gasLimit: <BN: 2625a00>,
  to: Address {
    buf: <Buffer cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc>
  },
  value: <BN: 186a0>,
  data: <Buffer 1a 84 51 e6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 18 more bytes>,
  v: <BN: 1>,
  r: <BN: afb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9>,
  s: <BN: 479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64>,
  common: Common {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    _supportedHardforks: [],
    _eips: [],
    _customChains: [],
    _chainParams: {
      name: 'ropsten',
      chainId: 3,
      networkId: 3,
      defaultHardfork: 'istanbul',
      consensus: [Object],
      comment: 'PoW test network',
      url: 'https://github.com/ethereum/ropsten',
      genesis: [Object],
      hardforks: [Array],
      bootstrapNodes: [Array],
      dnsNetworks: [Array]
    },
    DEFAULT_HARDFORK: 'istanbul',
    _hardfork: 'london',
    [Symbol(kCapture)]: false
  },
  chainId: <BN: 3>,
  accessList: [],
  AccessListJSON: [],
  maxFeePerGas: <BN: ff>,
  maxPriorityFeePerGas: <BN: 1>
}
[nodemon] clean exit - waiting for changes before restart

 

 

 

 

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

풀노드 구축  (0) 2024.03.13
graphsq + mongodb  (0) 2021.06.08
스마트컨트렉 함수 접근 방법  (0) 2020.12.08
token 송금  (0) 2019.10.28
rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
블로그 이미지

iesay

,

graphsq + mongodb

이더리움 2021. 6. 8. 13:20





wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -





echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-

org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list



apt-get update

apt-get install -y mongodb-org

​​

ps --no-headers -o comm 1


systemctl start mongod


systemctl status mongod

mongo


root@server:~# mongo
MongoDB shell version v4.4.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6b814716-52cb-4dde-8d9d-f365adc26916") }
MongoDB server version: 4.4.6
Welcome to the MongoDB shell.

>use admin

>db.createUser({ user: 'server', pwd: '1234', roles: ['root'] })

몽고 DB  ID/PASSWORD 설정

 


mongoimport --db beer-market --collection beers --file ./beers.json --jsonArray



bind_ip 를 0.0.0.0 으로 수정

service mongod restart


apt install npm

npm install

 

 npm init

 npm install express --save

 

 npm install express


npm install --save express express-graphql graphql

npm install nodemon -g

npm install node-cron

npm start

 

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

풀노드 구축  (0) 2024.03.13
EIP-1559 분석  (2) 2021.07.12
스마트컨트렉 함수 접근 방법  (0) 2020.12.08
token 송금  (0) 2019.10.28
rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
블로그 이미지

iesay

,

출처 :  

https://drhot552.github.io/blockchain/%EC%9D%B4%EB%8D%94%EB%A6%AC%EC%9B%80-%EB%B8%94%EB%A1%9D%EC%B2%B4%EC%9D%B8_Web3js%EC%8A%A4%EB%A7%88%ED%8A%B8%EC%BB%A8%ED%8A%B8%EB%9E%99%ED%8A%B8-%EC%8B%A4%ED%96%89%ED%95%98%EA%B8%B0/#%EC%8A%A4%EB%A7%88%ED%8A%B8%EC%BB%A8%ED%8A%B8%EB%9E%99%ED%8A%B8-%EC%8B%A4%ED%96%89


이더리음 스마트컨트렉 함수 실행하기

web3.eth.getTransactionCount(send_account, (err, txCount) => {

  const txObject = {

    nonce:    web3.utils.toHex(txCount),

    gasLimit: web3.utils.toHex(1000000), // Raise the gas limit to a much higher amount

    gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),

    to : "0x59c11C4Cc4B92Cc15A35E289F2df961E3E7BF548",

    data : MyContract.methods.setLock("0xAdE01D06890918738Ba85F82cd2BD08128b1E61b", 100).encodeABI()

  };

  const tx = new Tx(txObject);

  tx.sign(privateKey);

  const serializedTx = tx.serialize();

  const raw = '0x' + serializedTx.toString('hex');

  web3.eth.sendSignedTransaction(raw)

     .once('transactionHash', (hash) => {

       console.info('transactionHash', 'https://rinkeby.infura.io/tx/' + hash);

     })

     .once('receipt', (receipt) => {

       console.info('receipt', receipt);

       MyContract.methods.totalbalance().call().then(result => console.log("SmartContract Call: " + result));

    }).on('error', console.error);

  }); 


컨트렉 함수 : setLock

컨트렉 주소 : 0xAdE01D06890918738Ba85F82cd2BD08128b1E61b

대상 주소 : 0x59c11C4Cc4B92Cc15A35E289F2df961E3E7BF548


락걸린 대상의 송금 실패 내역





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

EIP-1559 분석  (2) 2021.07.12
graphsq + mongodb  (0) 2021.06.08
token 송금  (0) 2019.10.28
rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
erc20 token balance 조회  (0) 2019.10.24
블로그 이미지

iesay

,

token 송금

이더리움 2019. 10. 28. 17:43

출처 ㅣ https://codeday.me/ko/qa/20190930/1507276.html

 

 

금요일 사용 했던 소스

const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));
const toAddress = "0x7a0e3AB3c9626018850c06A099981F0B1f183D95";
const privateKey = "개인키";
web3.eth.accounts.signTransaction({
      to: toAddress,
      value: "300000000000000000",
      chainId: 4,
      gas: 210000
  }, 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 = "개인키"
const toAddress = "0x7a0e3AB3c9626018850c06A099981F0B1f183D95";

var tx = {
 to: toAddress,
 value: "300000000000000000",
 chainId: 3,
 gas: 21000
}


const app = async () => {
  try {
   var signed = await web3.eth.accounts.signTransaction(tx, privateKey);
   console.log('SIGN', web3.eth.sendSignedTransaction(signed.rawTransaction));

  }catch (error) { console.log('Task Failure',error);
 }
};
app();

 

 

 

금요일까지 잘되던 소스가 안되어서 오후 내 종일 삽질했네

# chainId
    0: Olympic, Ethereum public pre-release testnet
    1: Frontier, Homestead, Metropolis, the Ethereum public main network
    1: Classic, the (un)forked public Ethereum Classic main network, chain ID 61
    1: Expanse, an alternative Ethereum implementation, chain ID 2
    2: Morden, the public Ethereum testnet, now Ethereum Classic testnet
    3: Ropsten, the public cross-client Ethereum testnet
    4: Rinkeby, the public Geth PoA testnet
    42: Kovan, the public Parity PoA testnet
    77: Sokol, the public POA Network testnet
    99: Core, the public POA Network main network
    7762959: Musicoin, the music blockchain

 

바꿔서 실행해보고 안되면 또 삽질

 

 

 

 

 

어제 까지 잘 되었던 윗 소스가 오늘은 롭스톤에서 동작 안함

 

 

 

var Web3 = require("web3")
var web3 = new Web3("https://rinkeby.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537")
var privateKey = "0xA209084D071D63F598EB5C3A1B315CE8BDFED7906FF6D071CDADAB34244AAA69"
const toAddress = "0x7a0e3AB3c9626018850c06A099981F0B1f183D95";

var tx = {
 to: toAddress,
 value: "300000000000000000",
 chainId: 4,
 gas: 21000,
 gasLimit : 9000
}


const app = async () => {
  try {
   var signed = await web3.eth.accounts.signTransaction(tx, privateKey);
   console.log('SIGN', web3.eth.sendSignedTransaction(signed.rawTransaction));

  }catch (error) { console.log('Task Failure',error);
 }
};
app();

 

린케비에서 개발 다하고 나중에 메인넷에 한번 붙어 볼까 함

생각 보다 POS 전환 테스트 이더리움이 테스트넷에서 진행하면 조금 불안하다는

생각이 듬

 

 

 

 

 

const Tx = require('ethereumjs-tx').Transaction
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));

// set token source, destination and amount
var myAddress = "0x908C1B696B38B2647D93280d6b9deB951D61fA50"
var toAddress = "0xFf0797D06e8F9897B1D5066C10D9497Ed7054A47"
var amount = web3.utils.toHex(1e16)

// get transaction count, later will used as nonce
web3.eth.getTransactionCount(myAddress).then(function(v){console.log(v); count = v}) 

// set your private key here, we'll sign the transaction below
var privateKey = new Buffer('개인키', 'hex') 

// Get abi array here https://etherscan.io/address/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0#code
var abiArray = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[],"name":"stop","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"},
{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},
{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],
"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint128"}],"name":"push","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"name_","type":"bytes32"}],"name":"setName","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"stopped","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"wad","type":"uint128"}],"name":"pull","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"burn","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"start","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"guy","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"symbol_","type":"bytes32"}],"payable":false,"type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]
// Here you may get the abicode from a string or a file, here is a string case
// var abiArray = JSON.parse('[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"stop","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"},{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint128"}],"name":"push","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"name_","type":"bytes32"}],"name":"setName","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"stopped","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"wad","type":"uint128"}],"name":"pull","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"burn","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"start","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"guy","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"symbol_","type":"bytes32"}],"payable":false,"type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]', 'utf-8')

var contractAddress = '0xfcc242afa8d4f14c32d14798efc7110beadb1659'
var contract = new web3.eth.Contract(abiArray, contractAddress, {from: myAddress})

 


web3.eth.getTransactionCount(myAddress, (err, txCount) => {
    const app = async () => {
    try {
        var rawTransaction = {"from":myAddress,
         "gasPrice":web3.utils.toHex(2 * 1e9),
        "gasLimit":web3.utils.toHex(210000),
        "to":contractAddress,"value":"0x0",
        "data":contract.methods.transfer(toAddress, amount).encodeABI(),
        "nonce":web3.utils.toHex(txCount)}
        var transaction = new Tx(rawTransaction,{'chain':'rinkeby'})
        transaction.sign(privateKey)

        web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'))

        }catch (error) { console.log('Task Failure',error);
        }
    }
    app();
})


// check the balance
contract.methods.balanceOf(myAddress).call().then(function(balance){console.log(balance)})

 

- const Tx = require('ethereumjs-tx').Transaction

- var transaction = new Tx(rawTransaction,{'chain':'rinkeby'})

promise 뜨는 부분 함수로 바꾸었다.

예전 소스 안되어서 다시 구글링해서 만들었다.

 

 

 

 

 

https://rinkeby.etherscan.io/address/0xfcc242afa8d4f14c32d14798efc7110beadb1659

 

 

 

송금 전

 

 

 

 

송금 후

 

 

 

자바스크립트가 큰수를 처리 못해

amount 양이 적은경우가 있는데

아래 메세지가 나오는 경우

 

 Task Failure { Error: invalid number value (arg="wad", coderType="uint256", value="19e16")

 

var tokens = 3
var amount = web3.utils.toWei(tokens.toString(), 'ether')

변경 가능 10^18까지 스트링으로 처리해서 위에 메타마스크 모습 처럼 송금 완료.

 

 

 

 const Tx = require('ethereumjs-tx').Transaction
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));

// set token source, destination and amount
var myAddress = "0x908C1B696B38B2647D93280d6b9deB951D61fA50"
var toAddress = "0xFf0797D06e8F9897B1D5066C10D9497Ed7054A47"
//var amount = web3.utils.toWei(1, 'ether');

var tokens = 3
var amount = web3.utils.toWei(tokens.toString(), 'ether')

 

// get transaction count, later will used as nonce
web3.eth.getTransactionCount(myAddress).then(function(v){console.log(v); count = v}) 

// set your private key here, we'll sign the transaction below
var privateKey = new Buffer('개윈퀴', 'hex') 

// Get abi array here https://etherscan.io/address/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0#code
var abiArray = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[],"name":"stop","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"},
{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},
{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],
"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint128"}],"name":"push","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"name_","type":"bytes32"}],"name":"setName","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"stopped","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"wad","type":"uint128"}],"name":"pull","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"burn","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"start","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"guy","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"symbol_","type":"bytes32"}],"payable":false,"type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]
// Here you may get the abicode from a string or a file, here is a string case
// var abiArray = JSON.parse('[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"stop","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"},{"name":"wad","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint128"}],"name":"push","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"name_","type":"bytes32"}],"name":"setName","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"stopped","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"src","type":"address"},{"name":"wad","type":"uint128"}],"name":"pull","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint128"}],"name":"burn","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"dst","type":"address"},{"name":"wad","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"start","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"src","type":"address"},{"name":"guy","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"symbol_","type":"bytes32"}],"payable":false,"type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]', 'utf-8')

var contractAddress = '0xfcc242afa8d4f14c32d14798efc7110beadb1659'
var contract = new web3.eth.Contract(abiArray, contractAddress, {from: myAddress})

 


web3.eth.getTransactionCount(myAddress, (err, txCount) => {
    const app = async () => {
    try {
        var rawTransaction = {"from":myAddress,
         "gasPrice":web3.utils.toHex(2 * 1e9),
        "gasLimit":web3.utils.toHex(210000),
        "to":contractAddress,"value":"0x0",
        "data":contract.methods.transfer(toAddress, amount).encodeABI(),
        "nonce":web3.utils.toHex(txCount)}
        var transaction = new Tx(rawTransaction,{'chain':'rinkeby'})
        transaction.sign(privateKey)

        web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'))

        }catch (error) { console.log('Task Failure',error);
        }
    }
    app();
})


// check the balance
contract.methods.balanceOf(myAddress).call().then(function(balance){console.log(balance)})

 

 

 

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

graphsq + mongodb  (0) 2021.06.08
스마트컨트렉 함수 접근 방법  (0) 2020.12.08
rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
erc20 token balance 조회  (0) 2019.10.24
이더스캔 제작4 (개인별 잔액조회)  (0) 2019.10.22
블로그 이미지

iesay

,

https://www.rinkeby.io/#faucet

 

린케비에서 테스트 이더를 받기 위해서는 위 URL로 접속 한다.

롭스톤이나 다른 테스트넷은

 

 

 

게시물을 작성 후 퍼가기 클릭

 

이런 URL이 나온다 이중에 파란색 부분만 복사 해서,,,

 <iframe src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fgodam21321duc%2Fposts%2F2662232697177879&width=500" width="500" height="191" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>

 

아래와 같이 URL인코딩된거://     /  이런 문자열 재조합 한뒤에

이더리움 주소가 제대로 보이는지 확인 한다.

해당 게시물이 전체 공개로 되어 있어야 한다.

 

 

 

 

린케비에 등록하면  완료

 

 

 

 

5분이 지나면 메타마스크에서 테스트 이더 등록 완료.

 

테스트 이더도 많이 발급  못받게 할려구 SNS 기능을 넣은거 같다.

 

 

 

 

 

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

스마트컨트렉 함수 접근 방법  (0) 2020.12.08
token 송금  (0) 2019.10.28
erc20 token balance 조회  (0) 2019.10.24
이더스캔 제작4 (개인별 잔액조회)  (0) 2019.10.22
이더스캔 크롤링 json 저장  (0) 2018.12.06
블로그 이미지

iesay

,


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <script src="../js/web3.min.js"></script>
</head>
<body>

  <h1>Get ERC20-Token Balance</h1>

  <h2>Contract Address</h2>
  <input type="text" id="contract-address" size="80" oninput="onAddressChange()"></input>
  <p>ex> 0xcd45a142d109bbc8b22ff6028614027d1db4e32f</p>

  <h2>Wallet Address</h2>
  <input type="text" id="wallet-address" size="80" oninput="onAddressChange()"></input>
  <p>ex> 0x528018c88448f67d2b618a43546cf7e0b026857e</p>

  <h2>Result</h2>
  <span id="result"></span>

  <script>

    function getERC20TokenBalance(tokenAddress, walletAddress, callback) {

   
      let minABI = [
     
        {
          "constant":true,
          "inputs":[{"name":"_owner","type":"address"}],
          "name":"balanceOf",
          "outputs":[{"name":"balance","type":"uint256"}],
          "type":"function"
        },
        // decimals
        {
          "constant":true,
          "inputs":[],
          "name":"decimals",
          "outputs":[{"name":"","type":"uint8"}],
          "type":"function"
        }
      ];

    
      let contract = web3.eth.contract(minABI).at(tokenAddress);
 
      contract.balanceOf(walletAddress, (error, balance) => {
    
        contract.decimals((error, decimals) => {
       
          balance = balance.div(10**decimals);
          console.log(balance.toString());
          callback(balance);
        });
      });
    }

    function onAddressChange(e) {
      let tokenAddress = document.getElementById('contract-address').value;
      let walletAddress = document.getElementById('wallet-address').value;
      if(tokenAddress != "" && walletAddress != "") {
        getERC20TokenBalance(tokenAddress, walletAddress, (balance) => {
          document.getElementById('result').innerText = balance.toString();
        });       
      }
    }

    window.onload = function() {
      if (typeof web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);
      } else {
        web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/f76f49a440bf4303ab6d2c1aa21c7537"));
      }
      console.log(web3.version);
    }

  </script>
  <p>ex> https://mainnet.infura.io</p>
</body>
</html> 

 

 

출처 :https://medium.com/@piyopiyo/how-to-get-erc20-token-balance-with-web3-js-206df52f2561

 

web3.js는 최신 버전으로 잘 구해 넣어야 동작함 ..

 

블로그 이미지

iesay

,

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

 

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

rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
erc20 token balance 조회  (0) 2019.10.24
이더스캔 크롤링 json 저장  (0) 2018.12.06
이더스캔API erc20token 트렌젝션 조회  (0) 2018.11.30
입금주소 생성  (0) 2018.11.30
블로그 이미지

iesay

,

 

sample.json 데이터

 {
 "status":"1",
 "message":"OK",
 "result":[
  {
   "blockNumber":"4473164",
   "timeStamp":"1542787987",
   "hash":"0xac86d44f53a22e4b12853f5f8234f95b831e1521694c4072fd6a97b219ec3cb7",
   "nonce":"17012682",
   "blockHash":"0x4ee9b9d29f78f7aab230613f8827e9e070d5b60b2cd06d61e83b17aaaa5b1e67",
   "transactionIndex":"54",
   "from":"0x81b7e08f65bdf5648606c89998a9cc8164397647",
   "to":"0xff0797d06e8f9897b1d5066c10d9497ed7054a47",
   "value":"1000000000000000000",
   "gas":"21000",
   "gasPrice":"1000000000",
   "isError":"0",
   "txreceipt_status":"1",
   "input":"0x",
   "contractAddress":"",
   "cumulativeGasUsed":"6877760",
   "gasUsed":"21000",
   "confirmations":"104500"
                  }
    ]
}

result속의 데이터만 어떻게 가지고 올까 참 고민 많이 했다.

 

 var fs = require('fs');

console.log(result);
var initialData = fs.readFileSync('sample.json');
var TRList = JSON.parse(initialData);


var Result_data = [];
    for(var i=0; i<TRList.result.length; i++){
        var TR=TRList.result[i];
          var info = {
                  blockNumber: TR.blockNumber,
                  timestamp: TR.timestamp,

                  hash: TR.hash,
                  nonce: TR.nonce,

                  blockHash: TR.blockHash,
                  transactionIndex: TR.transactionIndex,

                  from: TR.from,
                  to: TR.to,

                  value: TR.value,
                  gas: TR.gas,

                  gasPrice: TR.gasPrice,
                  isError: TR.isError,

                  txreceipt_status: TR.txreceipt_status,
                  input: TR.input,

                  contractAddress: TR.contractAddress,
                  cumulativeGasUsed: TR.cumulativeGasUsed,

                  gasUsed: TR.gasUsed,
                  confirmations: TR.confirmations
        };
        Result_data.push(info);
    }
    var result={
        count: Result_data.length, // count
        Result_data: Result_data
    };
console.log(result);

TRList.result 저거 한줄을 못해서 ㅋㅋ 몇시간 동안 머한건지 ,,

 

 root@tkpark-VirtualBox:~/node# nodejs ex4.js
undefined
{ count: 1,
  Result_data:
   [ { blockNumber: '4473164',
       timestamp: undefined,
       hash: '0xac86d44f53a22e4b12853f5f8234f95b831e1521694c4072fd6a97b219ec3cb7',
       nonce: '17012682',
       blockHash: '0x4ee9b9d29f78f7aab230613f8827e9e070d5b60b2cd06d61e83b17aaaa5b1e67',
       transactionIndex: '54',
       from: '0x81b7e08f65bdf5648606c89998a9cc8164397647',
       to: '0xff0797d06e8f9897b1d5066c10d9497ed7054a47',
       value: '1000000000000000000',
       gas: '21000',
       gasPrice: '1000000000',
       isError: '0',
       txreceipt_status: '1',
       input: '0x',
       contractAddress: '',
       cumulativeGasUsed: '6877760',
       gasUsed: '21000',
       confirmations: '104500' } ] }
root@tkpark-VirtualBox:~/node#

 

이제 MongoDB에 집어 넣어 볼가?

var fs = require('fs');
var initialData = fs.readFileSync('sample.json');
var TRList = JSON.parse(initialData);
var mongoose = require('mongoose');
mongoose.connect('mongodb://test:12345@localhost:31337/test',
{
        useNewUrlParser: true
});
var db=mongoose.connection;
var PostSchema = new mongoose.Schema( {
        blockNumber: Number,
        timestamp: Date,
        hash: String,
        nonce: Number,
        blockHash: String,
        transactionIndex: Number,
        from: String,
        to: String,
        value: String,
        gas: Number,
        gasPrice: String,
        isError: Boolean,
        txreceipt_status: Number,
        input: String,
        contractAddress: String,
        cumulativeGasUsed: Number,
        gasUsed: Number,
        confirmations: Number
})
var Post = mongoose.model('Post',PostSchema);
var Result_data = [];
    for(var i=0; i<TRList.result.length; i++){
        var TR=TRList.result[i];
        var post_1 = new Post( {
                blockNumber: TR.blockNumber,
                timestamp: TR.timestamp,
                hash: TR.hash,
                nonce: TR.nonce,
                blockHash: TR.blockHash,
                transactionIndex: TR.transactionIndex,
                from: TR.from,
                to: TR.to,
                value: TR.value,
                gas: TR.gas,
                gasPrice: TR.gasPrice,
                isError: TR.isError,
                txreceipt_status: TR.txreceipt_status,
                input: TR.input,
                contractAddress: TR.contractAddress,
                cumulativeGasUsed: TR.cumulativeGasUsed,
                gasUsed: TR.gasUsed,
                confirmations: TR.confirmations
        });
                post_1.save(function (err) {
                if (err) return handleError(err);
                mongoose.disconnect();
        })
};

다 만들었다 거의 95%정도 완료 ...

save 부분에서 disconnet 해줘야지 백그라운드로 계속 프로세스가 돌지 않고

종료

 

 

 

 

DB에 박히는거 까지 확인

여기서는 조용해서 집중도 잘되고 문제 해결이 잘됨..

 

 

블로그 이미지

iesay

,

 

이더스캔API erc20token 트렌젝션 조회

 

https://api.etherscan.io/api?module=account&action=tokentx&

contractaddress=0xB8c77482e45F1F44dE1745F52C74426C631bDD52

&page=1&offset=100&sort=desc&apikey=@@@@

 

출처 : https://etherscan.io/apis#accounts

 

API키는 본인걸로 변경해야 된다.

가입해서 사용하면  된다.

 

 

블로그 이미지

iesay

,