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;
}
}
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.
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;