# Deployment failed with error: Returned error: sender doesn't have enough funds to send tx

**URL:** <https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539>\
**Category:** SDK\
**Created:** [March 29, 2020, 8:50am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539 "2020-03-29T08:50:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrackerHax](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/crackerhax/32/1880_2.png) [@CrackerHax](https://forum.openzeppelin.com/u/CrackerHax)\
**Post date:** [March 29, 2020, 8:50am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/1 "2020-03-29T08:50:43Z")

</div>

Any idea what can cause this to happen?

```
$ npx oz balance
? Enter an address to query its balance 0x....
? Pick a network development
Balance: 113353818.74917066 ETH

✖ Validating and deploying contract 
deployment failed with error: Returned error: sender doesn't have enough funds to send tx. The upfront cost is: 180143985094819820000000000 and the sender's account only has: 113353818749170660000000000
```

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [March 30, 2020, 3:53am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/2 "2020-03-30T03:53:20Z")

</div>

Hi @CrackerHax,

My first thought is that `gasPrice` is set very high in `network.js`.  
Are you able to share your `network.js`?

I was able to reproduce by setting the `gasPrice` to `5e18`.

## Deploy

Fails with high gas price.

```auto
$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy Box
✖ Deploying an instance of Box
Returned error: sender doesn't have enough funds to send tx. 
The upfront cost is: 25000000000000000000000000 and the sender's account only has: 100000000000000000000

```

## network.js

Default gasPrice is `5e9`.

```auto
module.exports = {
  networks: {
    development: {
      protocol: 'http',
      host: 'localhost',
      port: 8545,
      gas: 5000000,
      gasPrice: 5e18,
      networkId: '*',
    },
  },
};

```

## Box.sol

```auto
// contracts/Box.sol
pragma solidity ^0.5.0;

contract Box {
    uint256 private value;

    // Emitted when the stored value changes
    event ValueChanged(uint256 newValue);

    // Stores a new value in the contract
    function store(uint256 newValue) public {
        value = newValue;
        emit ValueChanged(newValue);
    }

    // Reads the last stored value
    function retrieve() public view returns (uint256) {
        return value;
    }
}

```

---

<div class="post-metadata">

**Author:** ![CrackerHax](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/crackerhax/32/1880_2.png) [@CrackerHax](https://forum.openzeppelin.com/u/CrackerHax)\
**Post date:** [March 30, 2020, 3:56pm UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/3 "2020-03-30T15:56:17Z")

</div>

gas: 0x1fffffffffffff, no price

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [March 31, 2020, 5:34am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/4 "2020-03-31T05:34:18Z")

</div>

Hi @CrackerHax,

What network are you deploying to for development? I am using `ganache-cli`  
What version of OpenZeppelin CLI are you using.

If I use your gas limit, then I get `Exceeds block gas limit` for a regular deploy using OpenZeppelin CLI 2.8.

## network.js

```auto
module.exports = {
  networks: {
    development: {
      protocol: 'http',
      host: 'localhost',
      port: 8545,
      gas: 0x1fffffffffffff,
      networkId: '*',
    },
  },
};

```

## Deploy (regular)

```auto
$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment regular
? Pick a network development
? Pick a contract to deploy Box
✖ Deploying an instance of Box
Returned error: Exceeds block gas limit

```

---

<div class="post-metadata">

**Author:** ![CrackerHax](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/crackerhax/32/1880_2.png) [@CrackerHax](https://forum.openzeppelin.com/u/CrackerHax)\
**Post date:** [March 31, 2020, 9:59am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/5 "2020-03-31T09:59:09Z")

</div>

Thing is I updated the contract maybe 7 or 8 times and it suddenly just started doing this.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 3, 2020, 1:24am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/6 "2020-04-03T01:24:15Z")

</div>

Hi @CrackerHax,

Unfortunately I haven’t been able to reproduce through upgrades, I ran about 8 upgrades on my development network (`ganache-cli`).

Are you still getting the error?

---

<div class="post-metadata">

**Author:** ![CrackerHax](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/crackerhax/32/1880_2.png) [@CrackerHax](https://forum.openzeppelin.com/u/CrackerHax)\
**Post date:** [April 3, 2020, 4:09am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/7 "2020-04-03T04:09:41Z")

</div>

I’m not getting an error message just a really high gas price. I am going to have to start over and redeploy all my contracts from scratch.

---

<div class="post-metadata">

**Author:** ![CrackerHax](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/crackerhax/32/1880_2.png) [@CrackerHax](https://forum.openzeppelin.com/u/CrackerHax)\
**Post date:** [April 4, 2020, 10:40pm UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/8 "2020-04-04T22:40:38Z")

</div>

Ok I redeployed all the contracts and its not doing it now.

---

<div class="post-metadata">

**Author:** ![AuroraLantean](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/auroralantean/32/6442_2.png) [@AuroraLantean](https://forum.openzeppelin.com/u/AuroraLantean)\
**Post date:** [June 4, 2021, 7:19am UTC](https://forum.openzeppelin.com/t/deployment-failed-with-error-returned-error-sender-doesnt-have-enough-funds-to-send-tx/2539/9 "2021-06-04T07:19:02Z")

</div>

In Hardhat, setting the gas and gasPrice solves it for me!  
hardhat: {  
gas: 7000000,  
gasPrice: 1000,  
}
