4

I'm currently developing a dapp in Solidity and want to frequently test it locally along with the updates - so I don't really want to redeploy it everytime to a test net. However, everytime I deploy it, the address the smart contract is deployed to changes, so I have to update my front-end code to the new address.

Is there a way to "force" the smart contract to always be deployed at the same address? Or is there any other equivalent solution you might think of?

Thanks!

Thanh-Quy Nguyen
  • 2,995
  • 7
  • 30
  • 46

2 Answers2

0

Faced the same problem. I don't know whether it legal but you can do:

in your migration file (migrations/1_example_migration.js)

var MyContract = artifacts.require("MyContract");

module.exports = function(deployer) {
    console.log(deployer);
    console.log(arguments);
    let n = 5; // it can be any address from list of available
    deployer.deploy(MyContract, {from: arguments[2][n]});
};

Documentation

Purusah
  • 9
  • 1
  • 1
0

you can get the account list you have by passing in the accounts argument like follows In the deploy_migration files :

module.exports = function(deployer, network, accounts) {
  // Use the accounts within your migrations.
}
Kaki Master Of Time
  • 1,428
  • 1
  • 21
  • 39