【发布时间】:2019-07-01 09:22:43
【问题描述】:
我正在开发一个解析 ABI 的 dApp,然后它会显示它的函数和每个函数变量的字段,我想将函数及其变量发送到 MetaMask 以进行交易。
我有一个完全 JS、web3.js 客户端网络 dApp。
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)
})
预期:将函数传递给 MetaMask 以完成交易
实际:我收到以下错误
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
【问题讨论】:
标签: blockchain ethereum smartcontracts web3 web3js