Here is my code:
$.getJSON('Adoption.json', function(data) {
// Get the necessary contract artifact file and instantiate it with truffle-contract
var AdoptionArtifact = data;
App.contracts.Adoption = TruffleContract(AdoptionArtifact);
// Set the provider for our contract
App.contracts.Adoption.setProvider(App.web3Provider);
// Use our contract to retrieve and mark the adopted pets
return App.markAdopted();
});
my question is:
I am using web3, ganache. Adoption.json is generate from command truffle compile
. Then I use truffle migrate
, truffle deploy this contract to ganache network. But from the code above, I don't need to specific the contract address, WHY? How does web3 know the contract's address?
Another question is, when I want to switch to Ropsten network, why I need a specific contract address?