Stelios Neophytides
Stelios Neophytides

How to pass the function of a parsed ABI to MetaMask?

I am developing a dApp that is parsing an ABI and then it shows the functions of it and fields that is for every function’s variable and i want to send the function with its variables to MetaMask to make the transaction.

I have a totally JS, web3.js client-side web dApp.

var miniToken = web3.eth.contract(abi).at(address) // Initialized in the proper function startApp()

const fntype = document.getElementById("function-name").value; var counter = $('.validate').length var NumOfValidates = counter-1; //A JS array that it will be filled with all the inputs the user give for each function's variable in order var variables = []; var id = 0; for (var i = 0; i < NumOfValidates; ++i) { id = id+1; variables.push(document.getElementById("i"+id).value); console.log("variable["+i+"] = "+variables[i]); } //SendToMetaMask miniToken.fntype(variables[1],{ from: address, value: '0'}) .then(function (txHash) { console.log('Transaction sent') console.dir(txHash) waitForTxToBeMined(txHash) })
I think now that my problem is that when i am taking the function name and put it in fntype variable, is not being recognized like a function but just as a string.

Any thoughts how to solve this?
Expected: Pass the function to MetaMask to complete the transaction

Actual: I get the following error

Uncaught TypeError: Cannot read property 'fntype' of undefined

at senddata2 (script.js:234)

at HTMLAnchorElement.onclick ((index):110)

senddata2 @ script.js:234

onclick @ (index):110