0

我已经部署了合同(不是我的),没有提供 abi。

交易中使用的输入数据:

0xd1700e6c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

有人可以帮忙,如何直接从 web3 调用这个函数?或者如何找出它的名字。据我了解,当您调用合约函数时,您会写:contract.methods.func().send(). 但是如果我只有methodId,如何调用/发送函数?

txid:https ://polygonscan.com/tx/0x165f8d6e2b5a75a4daad8950444e2c31bba027da0b8c1b21ac760a954e69af88

4

1 回答 1

0

您可以在字段中创建包含函数选择器(以及函数参数)的原始交易data,对其进行签名,然后将其发送给您的节点提供商以将其广播到网络。

// the sender private key needs to be added to web3 `accounts.wallet`
// see the blue "note" card in the docs for more details

await web3.eth.sendTransaction({
    from: senderAddress,
    to: contractAddress,
    data: "0xd1700e6c..."
});

文档:https ://web3js.readthedocs.io/en/v1.7.0/web3-eth.html#sendtransaction

于 2022-01-26T22:29:20.803 回答