0

I want to call a fucntion of deployed contract not deployed by me (I have a contract address and ABI), is it possible to do from truffle console? There are a lot of examples how to do it using js, but not using truffle. If it's possible, could you please provide me few examples?

Thanks!!

5
  • Do you have the source of the contract? It should be possible in any case, but it is easier with the source code.
    – Ismael
    Apr 6 '20 at 19:24
  • @Ismael yes, I have a solidity sourcecode
    – kedcex
    Apr 6 '20 at 19:34
  • The idea is to create a dummy project and add the source code to the contracts/ directory and configure to connect to the correct network. Once compiled you can launch console and run instance = await CompiledContract.at("0x123413241234...."), then you can call contracts with instance.sayHello("params").
    – Ismael
    Apr 6 '20 at 19:40
  • @Ismael, thanks for the answer. Do I have to migrate(deploy) this dummy project? Or just a compile will be enough? Also, as I know, at() function is depricated in truffle.
    – kedcex
    Apr 6 '20 at 19:54
  • It is not necessary to deploy, compiling is enough. I didn't know about at being deprecated, it works in truffle 5.1.17. I'd assume there is some kind of replacement.
    – Ismael
    Apr 6 '20 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.