I have the following contract:

pragma solidity ^0.4.24;

contract Escrow {

    address public owner;

    event LogReceivedFunds(address sender, uint amount);
    event LogReturnedFunds(address recipient, uint amount);

    constructor() public {
        owner = msg.sender;

    function() public payable {
        emit LogReceivedFunds(msg.sender, msg.value);

    modifier onlyOwner() {
        require(msg.sender == owner);

    function getBalance() public view returns (uint256) {
        return address(this).balance;

    function refundBalance() public onlyOwner {
        uint256 balance = address(this).balance;
        emit LogReturnedFunds(msg.sender, balance);

    function kill() public onlyOwner {

I successfully connected to Ropsten via Infura, as I can:

  1. Deploy the contract via truffle
  2. Run call on methods such as getBalance.

However, when I want to use send to alter the state (that is, refund the owner of the contract their deposited funds), I get this response:

Error: Invalid JSON RPC response: ""

This doesn't happen on Ganache, therefore I reckon it's a problem caused by Infura. Is there some sort of incompatibility?

  • The refundBalance function has the onlyOwner tag attached to it. When you are using infura, are you properly unlocking the owner account to access the contract? – Shawn Tabrizi Jul 28 '18 at 17:56

Infura doesn't support any operation that requires a private key (such as signing a transaction). This is because they don't store anybody's private key.

If you want to send a transaction via Infura, you have to sign it locally first (using your private key) and then broadcast the signed transaction via Infura.

  • Can you post an example how to prepare and sign a transaction that makes a changing-state contract call with arguments, please? – kitsune Feb 16 '19 at 4:40
  • @kitsune you can find that in this GitHub repo. Check out the js folder. – Paul Razvan Berg Feb 16 '19 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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