Let's suppose i've deployed a smartcontract and let's suppose i have deleted the solidity source code on my computer.

  • I know the deployed address
  • I know a function signature

What is the simplest way to call this function ?

I have tried web3js code but in my opinion it it is a very complex way


*** EDIT ***

Here is a basic web3js code. My main problem is i do not know the full ABI. I only know my function's signature (name, arguments and return type)

const Web3 = require('web3')
const web3 = new Web3("https://ropsten.infura.io/v3/<myprojectid>")
const ABI = [ { "inputs": [ { ... 
const instance = new web3.eth.Contract(ABI, "0x<contract_address>");
instance.methods.the_function_i_want_to_call().call((err, data) => {
  • It's pretty simple in web3.js, what exactly have you tried there which makes you think that "it is a very complex way"? Dec 13 '20 at 9:57
  • BTW, if you're asking for a simpler method, then you should obviously provide the method which you want to make simpler! Dec 13 '20 at 9:58
  • Thanks see my edit
    – Bob5421
    Dec 13 '20 at 12:15
  • My main problem is i do not know the full ABI: 1. This is not a problem, because you don't need the entire ABI, just the part related to the specific function that you want to call. 2. Assuming that you have indeed considered this a problem, why did you ask for "a simpler solution" and not just "a solution"??? There is nothing to simplify here. Dec 13 '20 at 12:39
  • Because this code is not simple to my opinion
    – Bob5421
    Dec 13 '20 at 12:41

The simplest without programming would be to use a wallet that supports interacting with a contract. It is possible to do that with Remix and Metamask.

To do so programmatically with the contract ABI use @trufle/hdwallet-provider or ethers.js.

It can be done without the ABI take a look at libraries like ethereumjs-abi. Then add the encoded function call to data parameter for sendTransaction.

Your Answer

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

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