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?
You need both the ABI and the contract bytecode to deploy your contract.
Once a contract is deployed, you need the ABI and the address of the deployed contract to interact with it. Multiple deployments of the same contract will have different addresses.
The ABI doesn't reveal everything about how your contract works. Just the interface. However, it's common practice to publicly post your contract code so others can review it for security concerns and build trust with those who want to use your contract. Transparency with your code doesn't mean that anyone can use your contract. You still control who can access your contract and in what ways (usually through modifiers).