I’m building a smart contract on Klever and want to let users verify that the deployed bytecode matches the open-source repository. My plan is straightforward: rebuild the contract reproducibly, hash the result, and compare it against what’s actually running on-chain. The problem is the last step. I can’t find a way to read a contract’s current code from its address.
The only approach I’ve found is to look up the transaction history, find the most recent deployContract or upgradeContract transaction, and pull the bytecode out of its data field (which is hex-encoded twice, with the WASM sitting between @ separators). This works, but it feels like the wrong tool for the job.
Is there a node or API endpoint that returns a contract’s code directly by address?
however validating the source code against the chain hash has a lot of underlying steps that might cause a mismatch, so i’d recommend trying the kleverscan way first, and if you have any feedback on it’s usage, let us know!