- from: String -The account address used for transmission. The web3.eth.defaultAccount property is used by default.
- to: String -(Optional) The destination address is not defined for the transaction that creates the contract.
- value: Number|String|BigNumber -(Optional) The value transferred for the transaction is in Wei, if it is a contract creation transaction, it is also a fund.
- gas: Number|String|BigNumber -(Optional, default: to be determined) The amount of gas used for transactions (unused gas has been refunded).
- gasPrice: Number|String|BigNumber -(Optional, default: to be determined) The gas price of this transaction is in wei, and the default is the average network gas price.
- data: String -(Optional) Either A byte string containing data associated with the message, or initialization code for creating a contract transaction.
- nonce: Number -(Optional) An integer of a random number. This allows you to overwrite your own pending transactions that use the same random number.
내가 구성한 시스템의 경우
django를 기반으로 api기능, front end pages 를 유저에게 제공한다.
front end pages의 경우 react js를 통해 만들어져서 전달되고 데이터가 필요한 경우 django api를 이용하는 구성형태이다
javascript selenium를 사용하려고 처음에 생각했다.
.
.
.
Module not found: Error can’t resolve ‘child_process’
Module not found: Error can’t resolve ‘fs’
Module not found: Error can’t resolve ‘tls’
에러 발생 아래와 같이 문제 해결
package.json이나 webpack confic, babel config 화일을 조정해서 문제해결
버전에 따라 조정해야 하는 config화일이 달라진다.

https://webpack.js.org/configuration/resolve/#resolvefallback
.

https://stackoverflow.com/a/67233156
.
.
.
그래서 selenium을 다운 받고 설치하고 webpack 으로 번들링 작업을 했지만 static property 부분에서 작업이 멈추고 지원할수 없는 화일이므로 알맞은 loader를 사용하라는 에러메시지가 떴다. (해결방법 못 찾음)
그 해결 과정에서 babel loader 기본 설정에서 사용되는 preset-env
@babel/preset-env
@babel/preset-env
is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s). This both makes your life easier and JavaScript bundles smaller!
실제 config 파일 사용예시는 아래에 있는 참고링크 참고
webpack5 config 설정 설명
.
.
static property 가 들어간 file번들링시 plugin-proposal-class-properties 필요할때도 있다. 일반적으로 최근 preset-env에 포함되어있는데 아닌 경우도 있을것 같아 아래 방법도 시도해 봤지만 실패

https://stackoverflow.com/a/60865451
.
.
.
문제해결을 위해 webpack 5로 업그레이드 시도했다.
webpack에 정보가 부족한듯 하여 webpack config기본 설정해 대한 유튜브 참고
이런경우 babel loader의 문제일수 있기 때문에 확인했지만 실패
결국 webpack 4로 돌아가고 selenium을 다운그레이드 했다.
이전의 문제는 해결되었지만 process.binding이 지원되지 않는 다는 새로운 에러 발생 (추측컨대 react js는 client 에서 돌아가는 작업들이기때문에 selenium을 이용하는 경우 사용자 컴퓨터를 마음대로 이용하게 될수도 있기 때문에 보안상 원천 봉쇄된걸로 파악)
그래서 server end에서 python selenium과 headless webdriver를 이용하기로 했다. react js(client side)에서는 api를 통해 작업을 요청하고 이용해서 결과 데이터를 받는 방향으로 결정
참고 링크
selenium docs https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/
.
selenim 이용해서 metamask조작하는 과정
https://dev.to/ltmenezes/automated-dapps-scrapping-with-selenium-and-metamask-2ae9
.
webpack 5 config file example
https://youtu.be/9c3dBhvtt6o 에서 전반적인 설명
https://gist.github.com/prof3ssorSt3v3/3e5fcbfae9ba28b5816fd93a074e65bd
const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { mode: 'development', //production entry: { main: path.resolve(__dirname, 'src/app.js'), }, output: { path: path.resolve(__dirname, 'dist'), filename: '[name].[contenthash].js', assetModuleFilename: '[name][ext]', clean: true, }, devtool: 'inline-source-map', devServer: { static: path.resolve(__dirname, 'dist'), port: 5001, //default 8080 open: true, hot: true, }, //loaders module: { rules: [ //css { test: /.css$/, use: ['style-loader', 'css-loader'] }, //images { test: /.(svg|ico|png|webp|jpg|gif|jpeg)$/, type: 'asset/resource' }, //js for babel { test: /.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], }, }, }, ], }, //plugins plugins: [ new HtmlWebpackPlugin({ title: 'Just a Demo', filename: 'index.html', template: path.resolve(__dirname, 'src/temp.html'), }), ], };

함수내에 변수를 만들면 외부와 분리 된다.
함수 밖에 만들어진 변수는 global scope가 되며 전체 script에서 접근 가능하게 된다

위는 변수의 scope를 제한하는 또다른 방법
.
.
이 동영상에서는 es6 사용을 추천해준다
.
.
.
아래는 common js를 사용하는 경우이다.
common js의 경우 exports를 사용
es6 는 export 를 사용한다
또 es6의 경우 경로를 나타내는 경우 화일명까지 포함시켜야 한다.






common js의 require는 함수이므로 일반 함수와 같이 사용될수 있고
아래와 같이 선택적으로 사용될수도 있다

.
.
.
.
.
es6





private key에서 public key를 만들고 public key에서 주소를 만든다
비트코인의 경우 address를 통해 받을수 있다.
비트코인을 보내는 경우 public key를 private key와 message로 signature를 만들고 이를 통해 검증된 경우에 비트코인을 보낼수 있게 된다.

아래는 HD WALLET 이 없는 경우 매번 private key를 만들고 이로부터 pubic key, address를 만들어 사용하는 경우이다. 이런경우 모든 private key를 track , back up 해야하는 문제 발생한다. 이 문제 해결책이 HD이다.

아래그림에서 수정해야 할부분
master public key는 비밀 보관할필요 없기때문에 점선 밖에 있어야 한다.
master public key를 다른 사람에게 주어서 다른 사람이 public key, address를 만들수 있게 할수 있다.

mnemonic words로 부터 master private key를 만든다.

.
.
.
.


시퀀셜 방법은 니모닉 단어들과 인덱스를 sha256에 통과 시켜 256비트의 해시된 스트링을 얻는 방법이다


bip 39은 니모닉을 생성하는 과정과 이를 이용해서 512비트 해시된 스트링을 얻는 방법을 설명한다

니모닉 단어 갯수에 따라 128-256비트의 값을 HMAC SHA512에 통과시키면 512비트 해시된 스트링을 얻을수 있고 이것의 앞256비트는 master private key, 뒤 256는 master chain code로 사용된다. master public key는 master private key에서 생성한다.

parent priv key , 2의 31승 – 2의 32승 사이의 인덱스값, parent chain code를 HMAC SHA512에 통과시키면 hash left, hash right(child chain code) 를 얻을수 있고 parent private key , hash left를 붙이면 child priv key가 된다. 여기서 child pub key도 생성할수 있다.
parent pub key , 0 – 2의 31승-1 사이의 인덱스값, parent chain code를 HMAC SHA512에 통과시키면 hash left, hash right(child chain code) 를 얻을수 있고 parent public key , hash left를 붙이면 child pub key가 된다.
위 과정을 반복하면서 계속 child priv, pub키를 만들수 있다.
이과정에서 HMAC SHA512에 넣는 parent priv, pub key는 master key를 계속 넣고 child chain code만 새로 생서된 계산값으로 바꾸어 넣어준다.



위 그림 내용을 보면 니모닉 단어들을 HMAC SHA512에 넣어서 얻은 값을 말하는지 이때 얻은 값을 산술합을 이야기 하는지 햇갈림













.
.
.
bip 39 library javascript
https://www.npmjs.com/package/bip39
.
bip 32 library javascript
https://www.npmjs.com/package/bip32
.
.
wallet관련 통합 library
https://www.npmjs.com/package/hd-address
https://www.npmjs.com/package/ethereum-hdwallet
.
.
.
참고자료)
Crypto Wallets, Backup, & Recovery: What is a Crypto Wallet Derivation Path?
설명이 매우 좋다.(일반인을 대상으로 한 설명)
.
.
https://river.com/learn/terms/b/bip-32/
BIP 32 is the Bitcoin Improvement Proposal which introduced the standard of Hierarchical Deterministic (HD) wallets and extended keys to Bitcoin.


















.
.
.
bip 39 library javascript
https://www.npmjs.com/package/bip39
.
bip 32 library javascript
https://www.npmjs.com/package/bip32
.
.
wallet관련 통합 library