I want to use Web3.php so that I send contract transaction to Ethereum blockchain.

I use the following code:

$web3 = new Web3('... node address ...');
$contract = new Contract($web3->provider, $contractAbi);
$contract->at($contractAddress)->send($methodName, $param1, $param2, 
    function($err, $result) {

It produces this error:

Uncaught RuntimeException: Wrong type of eth_sendTransaction method argument 0.

Now my main question is that where my private key must be provided in the code to sign the sent transaction.

1 Answer 1


Your private key is stored on the node you are running if you use Web3 like you are above.

  • 2
    eth_sendTransaction is a legacy method and it practice supported by 0% of Ethereum JSON-RPC nodes today. It has had no relevance to Ethereum development since 2016. You want to use eth_sendRawTransaction based transaction broadcasting, where transactions are signed using a local private key. Unfortunately I do not know how to do this in web3.php. Also you never send private key to anyone, anywhere, as anyone who can read this key can steal all of your assets. Jan 4 at 17:59
  • @ruby_newbie, Is blockchain node containing our private key????!!!!! Jan 6 at 16:01
  • Yes unless you use the provider based approach(which will sign using the private key attached to your web3 wallet. Jan 9 at 15:12

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.