0

I am working on Ubuntu 18.04. When I execute the “truffle migrate” command, I am getting first deploying and then replacing contract messages. Is this right? I am not sure about the code of 2_deploy_contracts.js for 2 contracts.

Somebody please guide me is my 2_deploy_contracts.js correct?

I am following the tutorial at:

Medium JustDev

The migration file 2_deploy_contracts.js is:

const Victim = artifacts.require('./Victim.sol')
const Attacker = artifacts.require('./Attacker.sol')

module.exports = function(deployer){
   deployer
     .deploy(Victim)
     .then(() =>
        deployer.deploy(Attacker, Victim.address)
     )
};

Is the above code correct?

Somebody pleae guide me about the code of deployment file.

Ganache Image after Deploying shows 8 at the top

1
  • That's a very long question, doubtfully anyone would read it all the way through (let alone answer it). Try to focus it on one specific issue (which is BTW a part of the rules for asking a question here). – goodvibration Jun 10 '20 at 19:14
1

yes it is in solidity version 0.4.8 the constructor function's name is the contract's name itself.

The attacker contract constructor function has a param and it is the address of the victim contract. So first he deploy Victim contract then after that he deploy Attacker contract with Victim contract address as the param for constructor function.

You can see the constructor example at this Creating Contract example at this doc: https://solidity.readthedocs.io/en/v0.4.8/contracts.html

1
  • When I run the code after correcting compilation errors, I am getting the messages that contracts are depolyed (i.e. both the Attacker and the Victim) but after that I am getting the message that "Replacing 'Victim'" and "Replacing 'Attacker'", however Ganache's image shows current block 8 (attached), can you please tell me whether 'Replacing' means contract removed from blockchain?? – zak100 Jun 11 '20 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.