Which function we need to use in truffle for the communication of second Dapp to the contract deployed on blockchain by first Dapp, because contract deployed by truffle is not accessible by geth node. I am trying using contractname.at(contractaddress), but it's not working?
1 Answer
When you deploy a contract, it gets assigned an Ethereum Contract Address. If you want to interact with a contract you must load the contract address to your wallet. (Take a look at how it is done with DAO: https://daohub.org/voting.html)
To interact with a Contract you need 2 things:
- The contract's Address
- The contract's JSON interface
By using these two you are able to load and invoke a contract onto web3.js and begin to interact with it.
navigate to 'Contracts'. Select then 'Watch Contract'. In the "Watch Contracts" interface, type 'The DAO' as the Contract name, paste the contract address, and the JSON interface. Click 'OK'.
With the contract interface registered, click "The DAO" in your custom contract section, and wait a few seconds. You are now able to use the interface and interact with the contract.
-
2I'm using truffle for testing. Do you know where truffle stores the ABI?– kramer65Commented Sep 12, 2016 at 7:28
-
the abi is in build/contracts/contractname.json Commented Dec 26, 2017 at 15:40
at()
should work. Might be helpful to post code.