2

I have created a smart contract and deployed it on ropsten with brownie framework.

Here are the steps I've done:

  1. Run the command:

    $ brownie init projet1
    
  2. I have created my contract in contracts/Contrat1.vy file

  3. I have run:

    $ brownie compile
    
  4. I have created an Ethereum account and I've sent some ether on it:

    $ brownie accounts generate mon_account2
    
  5. I have created this file for deployment: scripts/deploiement.py:

      from brownie import Contrat1, accounts
    
      def main():
        compte = accounts.load('mon_account2')
        t = Contrat1.deploy({'from': compte})
    
  6. I have created a project on infura and I've got a project id

  7. I have created an account and an API TOKEN KEY on etherscan

  8. I have run:

    $ export WEB3_INFURA_PROJECT_ID=<my_infura_projectid>
    $ export ETHERSCAN_TOKEN=<my_etherscan_api_token_key>
    
  9. I have run:

    $ brownie run deploiement --network ropsten
    

At this step, my contract is deployed on ropsten. Its deployment address is displayed on screen.

  1. Now I want to interact with this contract. So I have run:

    $ brownie console --network ropsten
    provider = Contract.from_explorer('<my_contract's_deployment_address>')
    
  2. I suppose I can now send transactions through provider variable.

Here are my questions:

  • My infura secret was not asked. So I suppose anyone can call my infura project url ?
  • Is there a way to avoid to work with Etherscan ? I have worked previously with truffle and it was not necessary to get an Etherscan account for deploying contract.
  • Is there a way to avoid to export WEB3_INFURA_PROJECT_ID and ETHERSCAN_TOKEN ? Is there a way to put these values in a project configuration file ?
  • When launching Contract.from_explorer, I get this error:

ValueError: Failed to retrieve data from API: Contract source code not verified

How should I fix that?

Thanks a lot

7
  • you need to upload the source code at etherscan website
    – Nulik
    Feb 3, 2021 at 18:01
  • Is there a way to do that automaticaly from brownie command line ? And is there a way to avoid this ? Thanks
    – Bob5421
    Feb 3, 2021 at 18:22
  • wget can help (or curl) : etherscan.io/sourcecode-demo.html
    – Nulik
    Feb 3, 2021 at 19:36
  • you don't need to verify source code in order to call a function in a contract, just deploy it the hard way and make a Call()
    – Nulik
    Feb 3, 2021 at 19:38
  • "Deploying a Smart Contract, The Hard Way" by Gustavo Guimares (medium.com)
    – Nulik
    Feb 3, 2021 at 19:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.