cchaining / qna

0 stars 0 forks source link

solc를 통해 compile 데이터에 prefix "0x" 오류 문제 #4

Open lazyker opened 6 years ago

lazyker commented 6 years ago
cannot unmarshal hex string without 0x prefix into Go struct field SendTxArgs.data of typehexutil.Bytes

Geth Version: 1.8.17-stable

puppeth 를 통한 모듈 설치 시 go-version이 1.10 < 1.11로 최근에 바뀌었음. 그런데 geth를 실행하는 go version은 1.10 https://github.com/ethereum/go-ethereum/commit/67c332e9b5c1afff65108abcc2b6883ace72abb9

solc를 사용하여 compile 하면 bytecode가 생성되는데 "608060405234801561001057600080fd5b5060008054600160a060020a0319163317905561040e806100326000396000f30060806040526........................................." 이런식으로 되어있음. prefix "0x"가 존재하지 않음. 기존에는 그래도 deploy가 되었던 것 같은데 없다고 오류를 뱉어냄.

찾아보니 https://github.com/ethereum/homestead-guide/blob/master/source/contracts-and-transactions/contracts.rst 이런 내용이 있음.

All binary data is serialised in hexadecimal form. Hex strings always have a hex prefix 0x.

기존에 배포 했을 때는 이런문제가 없었는데 추가 노드를 통해 배포를 하려니 이런문제가 발생. web3에서 deploy 할 때 자동으로 prefix를 해줬는데 호환성 문제 때문에 안붙혀주는 건지, 원래 prefix가 안붙어도 됐었는데 바뀐건지 go version이 달라서 뭔가 인지를 제대로 못하는건지 확실하지 않음.

우선 해결

bytecode 앞에 "0x" 붙혀서 배포하니 배포됨.