1

I'm creating web3 instance

            $web3 = new Web3(
                        new HttpProvider(
                            new HttpRequestManager(
                                config('infura.endpoint'),       // url
                                5.0                              // timeout
                            )
                        )
                    )
            ;

Then instance of my contract

$contract = new Contract($web3->provider, $abi);

I must call this function

    {
        "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"
    },

I am trying

$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);
        }
    )
;

The problem is that send throws an Exception. The Exception's message is

"Wrong type of eth_sendTransaction method argument 0."

Could you please explain me how to use the send method?

EDIT 1:

I tried a different syntax

$contract->at(config('infura.contract_address'))
    ->send('set', 22, 'hello world', [ 'from' => config('infura.wallet_address') ], function($error, $result) {
            dd("error", $error, "result", $result);
        }
    )
;

But I got a more fun differenct exception

The method eth_sendTransaction does not exist/is not available at web3.php\src\RequestManagers\HttpRequestManager.php

1 Answer 1

0

I found myself the problem.

Infura doesn't support unsigned transactions.

Actually I've not found how to use sendRawTransactions (and to sign). but this is a whole other question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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