I am practice to Truffle to build my contracts.
When I finished my contract, open testrpc.
And use this command line as blow to deploy my contract.
truffle migrate
Etherenum can get my deployed contract info if I write some code in my app.js as blow:
if (typeof web3 !== 'undefined') {
App.web3Provider = web3.currentProvider;
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
App.web3Provider = new
Web3.providers.HttpProvider('http://localhost:8545');
web3 = new Web3(App.web3Provider);
}
$.when(
//load my contract json file
$.getJSON('Crowdsale.json', function(data)
{
var CrowdsaleTokenArtifact = data;
App.contracts.Crowdsale =
TruffleContract(CrowdsaleTokenArtifact);
// Set the provider for our contract.
App.contracts.Crowdsale.setProvider(App.web3Provider);
).then(function(){
// start do something
});
})
How does Etherenum get my contract info?
Because I don't tell Etherenum which one is my contract on the Etherenum net.
I just load my contract json file, and Etherenum can get my contract info.
Does it mean, if someone have my contract json file. They can do the same thing as I can do in the contract?
If there have another deployed contract that have the same name or same code structure like mine.
How does Etherenum recognize it?