벤치프레스 자세

다이어트 2019. 11. 15. 22:43

 

벤치 프레스


1] 스미스 머신으로 하기

 

2] 젖꼭지 동선 맞추기

 

3] 손모양은 엄지손가락 빼기

 

4] 쫍게 잡기

 

5] 자극은 삼두랑  가슴 다른쪽 자극은 자세 잘못 된거

 


6] 아치형

 

7] 일반 벤치프레스도  5kg달고 하기

 

8] 95% 정도까지 밀고 가슴에 닿지 않게 하기

 

'다이어트' 카테고리의 다른 글

다이어트2  (0) 2020.02.03
블로그 이미지

iesay

,

환경 구축

Indy 2019. 11. 13. 11:42
블로그 이미지

iesay

,

orbs-network 설치

Orbs Network 2019. 11. 6. 12:13

'Orbs Network' 카테고리의 다른 글

orbs-client-sdk-python  (0) 2019.11.05
블로그 이미지

iesay

,

출처 : https://github.com/orbs-network/orbs-client-sdk-python

파이썬 클라이언트 노드 부터 설치 해봤다.

 

Orbs Network를 한번 파볼려구 한다.

[하이퍼레저 패브릭] 이 Private Blockchain에서 성능이 구려서 소스코드를 수정해서 사용중인건 다 알고 있다.

 

이더리움을 POA 모드로 사용하기도 하고

Orbs Network 메인넷의 일부를 OOOO에서 별도로 연동 하였다던데

나도 내가 만들어 보고 싶은 프로젝트에 연동 할려구 한다.

 

내가 원하는 블록체인  프로젝트의 요구사항은

아래와 같다.

 

1] 리모릭

2] 스마트컨트렉 LevelDB

3] 트래커 스캔

4] 합의 알고리즘 존재

 

apt-get install python3-pip

https://github.com/orbs-network/orbs-client-sdk-python.git

pip3 install subprocess.run

pip3 install setuptools

pip3 install securesystemslib
 

 

 

 

 

>>> print(sender)
Account(public_key=b'sH\x82\xc6$&aj\x04 \xfe\x85\x01t\xf0\x98@`a\xe6\x91\xad\xab?\x83cg\xf6\xa3\xc9S,',
private_key=b'\xca\x06\xc1Db\x03\xe5M\x1b\xb2\x16=\xd8\xac\x1b\x1c{\x1c\x8d\xc7\x9c\r\xd3-\xd6\xe8%\xd3\x04\xe3\t[sH\x82\xc6$&aj\x04 \xfe\x85\x01t\xf0\x98@`a\xe6\x91\xad\xab?\x83cg\xf6\xa3\xc9S,',
address='22Nr2jUT32nqZAbHzCLZXrhvhB8C', raw_address=b'I{\x87\x7f\xdf\x807\xf4\xd3\x81\xc1\xca\xdaT\\B?\x1c\xbf\xd9')

 

 

 

 

 

 >>> print(receiver)
Account(public_key=b'\x89?]\xecK\x1d=\x85\xbfKj\xdb\xd0\x85=S\xd2\ta(R\xd8J\xd4\xd6OC\xae\xed\r\x93\x1f',
private_key=b'\xec\xcd\xf5\x8a\xdf\xc3\xb3w\x00\x94\xe2\xdfe\x8e\xe3\xcbgx\xf3#\xee6,J\xbc\xb4\x98\xc5K\xbf(q\x89?]\xecK\x1d=\x85\xbfKj\xdb\xd0\x85=S\xd2\ta(R\xd8J\xd4\xd6OC\xae\xed\r\x93\x1f',
address='3LRFVUTnwpFkpVXWs1mhHqaYiex', raw_address=b'\x02\xe3\xb3\xe1\xb1\x89-\xa3jY`8\xd6\x9d=@\xbf\xe3\xafE')
>>>

 

'Orbs Network' 카테고리의 다른 글

orbs-network 설치  (0) 2019.11.06
블로그 이미지

iesay

,

vscode , 버추얼박스

시스템 2019. 11. 5. 11:08

출처 : https://noooop.tistory.com/entry/VS-Code-Remote-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-SSH-%EB%B0%A9%EC%8B%9D

 

버추얼박스로 우분투19 자원은

cpu core개 램은 6기가 정도가 적당하다.

 

Root 계정이 접속 가능하도록 우분투 세팅을 바꾼다.

그래서 Putty든  vscode든 다 root로 접속하는게 작업 하기 편하다.

 

cd /etc/ssh

vi sshd_config

 

# Authentication:

LoginGraceTime 2m
PermitRootLogin yes
StrictModes yes

 

service ssh restart

 

config설정 완료하면 나중에 패스워드 입력 하라는 창이뜬다

입력하면 완료.

 

 

 

'시스템' 카테고리의 다른 글

우분투 No space left on device  (0) 2020.06.26
gitlab 설치  (0) 2020.04.07
버추얼박스 VT-x is not available 오류  (1) 2019.07.18
시놀리지 나스 synology nas(redmine plugin)설치  (2) 2019.04.29
pm2  (0) 2019.03.28
블로그 이미지

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

,

스마트컨트렉을 활용한 문서 위변조 탐지 시스템

https://news.naver.com/main/read.nhn?mode=LSD&mid=sec&sid1=101&oid=009&aid=0004435247

 

세계지식포럼에서 비탈릭부테린도 문서 위변조 탐지에

블록체인이 적합 하다고 하였다.

그래서 어떤식으로 구현하면 좋을지 방법론을 한번 고민해 보았다.

 

기존방식의 졸업증명서나 성적증명서의 경우

ActiveX를 활용하여 출력물에 워터마크를 찍는 방식이다.

 

스캔하면 훼손되는 부분인데  이런 방식은 워터마크는 그대로 있더라도

원본이 훼손된 경우는 위변조에 대한 판단이 불가능하다.

 

그리고 중국의 유명한 술은  일부 RFID와 DataBase를 쓰는 경우도 있다

이 경우도 DataBase가 직접 훼손될 가능성도 있다.

아니면 칩만 떼서 다른곳에 붙여도 위조가 가능하다.

 

그래서 OO장관 사태와 관련해서도

이런 문제점을 어떻게 블록체인으로 보완할수 있을까? 고민을 한번 해보았다.

 

 

증명서당 하나의   개인키(지갑주소), 스마트컨트렉을 가지고

그 컨트렉 levelDB에 데이터를 저장하면 되지 않을까? 하는 생각이 들었다.

 

지원자의 서류를 검토한다는건 

당연 개인정보 수집동의를 허락 한것이라고 본다.


그래서 그 서류에 대한 진위여부를 판단 하는것도  합법적인 행위이다.



1] 표창장의 값들을 mnemonic word의 Seed로 사용한다.(개인키)

   아래 값을 Seed로 쓴다면

 

mnemonic word (랜덤으로 매번 다른값이 생성 될것이다) 

 armor cactus zero point casual address park doll hobby arch chest tobacco

 

Seed

제02-34512,    알아서머할래,    박태광 

seed값을 자유롭게 생년월일이나 성적이나 몇몇 개인정보도 입력이 가능하다.

 

2] 스마트컨트렉

스마트컨트렉 LevelDB에  값들을 저장해 놓는다.

제02-34512,    알아서머할래,    박태광 

 

 

 

3] 표창장이나 증명서 아래에 [mnemonic word +seed] QR태그를 넣어 놓는다.

 

4] 스마트폰으로 해당값을 스캔 하면

스마트컨트렉에서 해당 컨트렉을 만든 지갑주소가 맞음으로 LevelDB에 저장된 데이터를 출력시켜 준다.

만약 [LevelDB의 데이터] [증명서][seed] 3개가 일치하지 않는다면 위조로 판단할수 있다.

 

mnemonic 이나 Seed값이 저장된 QR코드를 모르거나 변조된다면

해당 컨트렉에 저장된 값을 볼수가 없다.

 

문제점은 누가 노드를 해킹하여 강제로 증명서 컨트렉의 계정을 생성해서

발급할 수 있다.

 

그래서 꼭 오프라인 발급대장과 트랜젝션을 확인하는 과정을 거처야 된다.

 

위 방법을 거치면 워터마크나 RFID보다 훨신 더 안전하게  위변조를 방지할수 있다.

 

 

산출물만 적다면 위 아이디어로 정부 과제라도 해보고 싶다.

 

블록체인이라 부르지 말고 왜 Trust System이라고 부르고 싶어 하는지도 이해 된다.

 

 

 

 

 

 

 

 

 

 

 

 

 

블로그 이미지

iesay

,