https://ethereum.stackexchange.com/a/124027

  • Get rid of any library (like that of OpenZeppelin’s Enumerable or Ownable) whose only few functions you would need. Instead, define those specific functions yourself. (이 방법은 실제로 stellaiam 개발시 사용해봄 효과 있음)
  • Identify any public variables that can be made private, the compiler adds a getter function by itself which adds to the code size.
  • If you have a lot of comments, get rid of them or shorten them.
  • The last resort: try to shorten the error message, variable names.

.

.

.

modifier에 코드를 작성해서 그냥 사용하지 말고 다른 함수에 코드를 작성하고 modifier에서는 함수를 호출하는 방식으로 하면 사이즈가 줄어든다. 실제 Ownable 코드를 확인해 보면 이미 안에 이런 형식 형식으로 작성되어있다. 그래서 stellaiam개발시 사용해보지는 못했다.

 https://youtu.be/XDqD3X8DCiw

const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
// Prompt user for account connections
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
console.log("Account:", await signer.getAddress());

https://stackoverflow.com/a/67836760

node가 front end처럼 작동할때는 fs에 접근이 불가능하다. 즉 front end에서는 보안문제 방지를 위해 사용자의 컴퓨터 파일 시스템에 접근이 불가능하다. 

.

.

npm canvas를 이용해서 front end쪽에서 이미지를 create 한경우 fs 라이브러리를 사용할수 없기때문에 만들어진 이미지를 저장할수는 없지만 src path를 얻어서 바로 ui에 포함시킬수 있다.

https://stackoverflow.com/a/67231182

canvas.toDataURL()

.

.

민감한 정보는 dot env를 통해 따로 관리힌다

official doc : https://www.npmjs.com/package/dotenv

create-react-app 으로 만들어진 앱의 경우 webpack config 화일은 

The files are located in your node_modules/react-scripts folder 안에 있다.

https://stackoverflow.com/a/48395890

.

.

react checkbox event handle

https://stackoverflow.com/a/51264645

.

.

object를 가지고 있는 useState 업데이트 방법

// To resolve that you need to use object destructing every time
// results will be state = {first: 3, second: 2}
setState(prev => ({...prev, first: 3}))

https://stackoverflow.com/a/71093607

.

.

react와 dot env를 같이 사용하는 경우 주의 사항이 있는데 확인해야 한다

https://medium.com/how-to-react/using-env-file-in-react-js-b2714235e77e

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

https://stackoverflow.com/a/65556946

const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")

module.exports = {
    // Other rules...
    plugins: [
        new NodePolyfillPlugin()
    ]
}

예를 들어 ethereum main net에 있는 모든 erc 1155의 transfer event를 watch한다고 하면 어떻게 해야 할까? 라는 질문에 내가 생각한 방법은

ethereum node를 운영하면서 생성되는 모든 컨트랙트를 데이터베이스에 기록한다.

새로 생성되는 contract의 경우 OwnershipTransferred 이벤트가 발생하고 여기에 

previous owner  주소가 0x0000000000000000000000000000000000000000 인경우가 새로 생성된 contract이고 이 contract가 erc 1155 를 implementing 하는지 확인하고 데이터베이스에 기록한다. 

이렇게 하면 ethereum main net에 존재하는 모든 erc 1155의 컨트랙 주소를 얻을수 있고 이들 주소의 transfer 이벤트를 watching한다면 etherum main net의 모든 erc 1155 transfer event를 트래킹할수 있다.

아마도 etherscan이나 opensea에서 이런 방법을 사용하는게 아닌가 싶다