4

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?

7
  • What do you mean by first and second dapp? Also, the addresses of your contracts are permanent, so as long as you used the same node for deploying your contracts, the method you described with at() should work. Might be helpful to post code. Commented May 12, 2016 at 12:50
  • look, i deployed a contract from a dapp running on a geth node. Now i want to access the functions of the deployed contract using another dapp running on a different node. what is needed? Consider testnet.@Karl Floersch
    – BlockA
    Commented May 12, 2016 at 14:34
  • You'll need the contract's ABI and address to call the contracts functions from another Dapp. You'll want to understand how to create contract objects in web3 and pudding. github.com/ethereum/web3.js & github.com/ConsenSys/ether-pudding Commented May 12, 2016 at 23:15
  • I am using truffle framework, which has pudding functionality. I have compiled the same contract on the both Dapps and deployed it on the one Dapp. Now i am trying to access it from another Dapp using the truffle method contractname.at(contractaddress) and when i call the functions of the contracts, it returns me the error "Uncaught BigNumber Error: new BigNumber() not a base 16 number." Sam error for all the functions returning string, "0x" for the functions returning address. Don't know what to do?? @Karl Floersch
    – BlockA
    Commented May 13, 2016 at 7:23
  • OK good! So you got it to work. The error you're getting is unrelated. Look up how to deal with web3 big numbers. They can be a little tricky. But at least you've got what you initially set out to do working I believe. Commented May 13, 2016 at 17:53

1 Answer 1

1

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.

2
  • 2
    I'm using truffle for testing. Do you know where truffle stores the ABI?
    – kramer65
    Commented Sep 12, 2016 at 7:28
  • the abi is in build/contracts/contractname.json Commented Dec 26, 2017 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.