How Could I pull out smart contract bytecode using web3 and contract address?
Asked
Active
Viewed 1,487 times
1 Answers
1
Using Web3.js you can easily extract the bytecode for a contract at a certain address using the getCode() function:
web3.eth.getCode(address [, defaultBlock] [, callback])
web3.eth.getCode("0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8")
.then(console.log);
> "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
Shawn Tabrizi
- 8,008
- 4
- 19
- 38
-
I thought this will be it, but its not. This is getting current sc bytecode, I was looking for something to get bytecode so I can use it to deploy new sc – Damian Klepacki Nov 27 '18 at 18:44
-
It's not that simple unfortunately: https://ethereum.stackexchange.com/questions/7735/bytecode-on-block-chain-different-from-the-one-used-when-deploying – Shawn Tabrizi Nov 27 '18 at 19:41