I am very new to dApp-Development and therefore frankly i need some basic help. How can i get the address of my deployed contract by truffle in meteor? I hope there is a simple solution.
Truffle writes the address it deploys to during deployment when you run it, but afterwards it also stores the information about the deployed contracts under a directory called
build/contracts. Each contract gets its own .json file, so if your contract is called
MyContract you should have a file called
The address of the contract will be towards the end of the file, in a field called
address. Note that if you have deployed to multiple networks, you may have an
address entry for each one, so you need to look through the file and make sure you have the right network. (It groups the entries by Network ID.)
To interact with the contract it's not enough to have the address. You will also need the ABI, which is the definition of the functions that your contract exposes. This is also found in the .json file generated by Truffle. You could pull this out and read it directly with web3.js, but it's easier to use the
truffle-contracts library. That way you don't need to worry about finding the address either: just point Truffle's library to the JSON file and let it work out how to load the contract.
See this question for an example of reading the contract json file and interacting with it using
truffle-contracts: Export a JS package from Truffle?