我正在创建web3实例
$web3 = new Web3(
new HttpProvider(
new HttpRequestManager(
config('infura.endpoint'), // url
5.0 // timeout
)
)
)
;然后我的合同实例
$contract = new Contract($web3->provider, $abi);我必须调用这个函数
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "_index",
"type": "uint256"
},
{
"internalType": "string",
"name": "_data_to_store",
"type": "string"
}
],
"name": "set",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},我在努力
$contract->at(config('infura.contract_address'))
->send('set', 22, 'hello world', function($error, $result) {
// this is Laravel dump to screen and die command
dd("error", $error, "result", $result);
}
)
;问题是发送会抛出异常。异常的消息是
“错误类型的eth_sendTransaction方法参数0”
请你解释一下如何使用发送方法好吗?
编辑1:
我尝试了另一种语法
$contract->at(config('infura.contract_address'))
->send('set', 22, 'hello world', [ 'from' => config('infura.wallet_address') ], function($error, $result) {
dd("error", $error, "result", $result);
}
)
;但我有一个更有趣的不同的例外
web3.php\src\RequestManagers\HttpRequestManager.php中不存在/不可用的方法eth_sendTransaction
发布于 2020-01-22 08:46:18
我发现了自己的问题。
恩弗拉不支持未经签署的交易。
实际上,我还没有找到如何使用sendRawTransactions (和签名)。但这是另一个问题
https://ethereum.stackexchange.com/questions/79164
复制相似问题