CoffeeBeans
CoffeeBeans

Reputation: 41

Terminal getting stuck at 'Awaiting transaction in the mempool' while using Brownie deploy function

When I run brownie run scripts/deploy.py, the terminal prints 'Awaiting in the mempool' infinitely. My smart contract has no constructor.

from brownie import accounts, config, SimpleStorage

def deploy_simple_storage():
    account = accounts[0]
    print(account)

    simple_storage = SimpleStorage.deploy({'from': account})
    stored_value = simple_storage.retrieve()
    print(stored_value)


def main():
    deploy_simple_storage()

One terminal is running "npm run ganache" and here's my package.json file,

{
  "dependencies": {
    "ganache": "^7.0.3",
    "ganache-cli": "^6.12.2"
  },
  "scripts": {
    "ganache": "ganache --wallet.seed myCustomSeed"
  }
}

Terminal 2 is running brownie run scripts/deploy.py When I kill this terminal, I get the following message,

raise TransactionNotFound(message)  
web3.exceptions.TransactionNotFound: Transaction with hash: '0x28da598c177dba438a6d8dee44ef3737ee1141d9435c00a42cd7ca481a58f99b' not found.

Here's the Youtube video that I am following if it's helpful https://www.youtube.com/watch?v=M576WGiDBdQ&t=16421s @4:43:48

SmartStorage.sol:

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

contract SimpleStorage {
    uint256 favoriteNumber;

    struct People {
        uint256 favoriteNumber;
        string name;
    }

    mapping(string => uint256) public nameToFavoriteNumber;

    function store(uint256 _favoriteNumber) public {
        favoriteNumber = _favoriteNumber;
    }

    function retrieve() public view returns(uint256) {
        return favoriteNumber;
    }

    function addPerson(string memory _name, uint256 _favoriteNumber) public {
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber;
    }
}

Upvotes: 0

Views: 857

Answers (3)

Alex
Alex

Reputation: 101

I had the same issue on an Ubuntu 20.04 machine, I still don't fully understand it, but it seems that if you have any ganache server running in the background while trying to deploy/test on a network that was manually added using a fork, then you should stop it, for all the other ones you should still have to run your ganache server in the background.

From what I can tell, the problem seems to be that a port conflict is happening between the ganache server that you run in the background and the ganache server that is started when you run your deployment/testing scripts on those specific networks.

Upvotes: 1

Sultan
Sultan

Reputation: 61

I'm following that same course and faced the same issue.
It worked after adding ganache-local as a network for brownie, as done later in the video you linked. https://youtu.be/M576WGiDBdQ?t=20295 (5:38:15)

brownie networks add Ethereum ganache-local host=http://127.0.0.1:8545 chainid=1337

As for the warning, you can safely ignore it. It's just telling you that the ganache blockchain you're running has a block height of x.

Upvotes: 0

Yilmaz
Yilmaz

Reputation: 49351

retrieve function seems correct but there is a bug in addPerson. I am not sure if this will solve it but you are pushing People type to people but people is not defined:

function addPerson(string memory _name, uint256 _favoriteNumber) public {
        // people is not defined
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber;
    }

since it has push method, it must be an array defined like this:

    People[] public people;

Upvotes: 0

Related Questions