Verify Your Truffle Compiled and Deployed Contract on Etherscan
When asking users to thrust your smart contract code it may be important to share.
What you will learn
- Where verify your truffle compiled and deployed contract on etherscan fits into an Ethereum application.
- Which assumptions should be tested before a mainnet deployment.
- What to read next when this concept is working.
When asking users to thrust your smart contract code it may be important to share the code of the contract with them. Linking to the project source code from Github may not be enough as there is no guarantee that the code you show is the same as the code that runs your smart contract. You can see a list of verified smart contracts on Etherscan.io.
First of all, once you published you smart contract to the main net or any test network you need to find it on Etherscan by using the search field.
For a fixed-precision contrast with wei and ether, use the exact BTC and satoshi denomination calculator.
Once on your smart contract page, navigate to the Contract code tab and click on Verify and publish .
As the truffle framework optimize your contract, you’ll need to verify your contract source code in the new interface by clicking new Beta Source Code Contract Verifier .
For display-value checks, compare the application output with the ETH-to-USD informational converter, then account separately for fees and slippage.
You will then need to enter the name of your contract. The name must exactly match the one in your source code.
Then select the version of your Solidity compiler. If you are not sure about which version you are running, you can get it by typing solc –version in your terminal.
Issuance assumptions are easier to see on the Bitcoin supply, subsidy, and halving calculator.
You then need to paste the code of your contract in the code text box. At this point, if you have any import you will need to manually remove them and copy and paste the content of the file instead of the import statement. If you want to go faster, you may check Blockcat solidity-flattener, a tool that will automatically concatenate the files for you.
If you deployed a contract which contained constructor arguments, you’ll need to add them in the following input box. Constructor arguments are expected to be ABI-encoded. More information on ABI-encoding can be found on the page, but remember that the constructor arguments are written right to left.
In the additional parameters section, you should check the number of times the optimizer is runt. For contracts compiled with Truffle, the correct default value for runs is 0.
Turn the example into production evidence
A working demo is the beginning of verification, not the end. Add tests for failure paths, inspect every permission, and record the chain, contract address, compiler, and dependency versions used for the deployment.
Check behavior
Test expected inputs, boundary values, reverts, events, and calls made to other contracts.
Check operations
Plan key storage, monitoring, pause or upgrade authority, and a response if an assumption stops being true.