Hello,
I’m trying to figure out how to deploy a smart contract onto the Polygon Mumbai Test network using Moralis. Here’s how I’m attempting to deploy using Python/Brownie. Unfortunately, I’m getting the following error on deploy:
File "brownie/_cli/run.py", line 50, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/integration_test/deploy_factory_only_Moralis.py", line 63, in main
deploy_factory_contract()
File "./scripts/integration_test/deploy_factory_only_Moralis.py", line 52, in deploy_factory_contract
nft_factory = deploy_factory(networkType=network_type,
File "./scripts/deploy_factory.py", line 15, in deploy_factory
factory_contract = MyFactory.deploy(
File "brownie/network/contract.py", line 528, in __call__
return tx["from"].deploy(
File "brownie/network/account.py", line 510, in deploy
receipt, exc = self._make_transaction(
File "brownie/network/account.py", line 744, in _make_transaction
response = self._transact(tx, allow_revert) # type: ignore
File "brownie/network/account.py", line 842, in _transact
return web3.eth.send_transaction(tx)
File "web3/eth.py", line 719, in send_transaction
return self._send_transaction(transaction)
File "web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "web3/manager.py", line 197, in request_blocking
response = self._make_request(method, params)
File "web3/manager.py", line 150, in _make_request
return request_func(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/gas_price_strategy.py", line 89, in middleware
return make_request(method, (transaction,))
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "web3/middleware/attrdict.py", line 33, in middleware
response = make_request(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 74, in apply_formatters
response = make_request(method, formatted_params)
File "web3/middleware/buffered_gas_estimate.py", line 40, in middleware
return make_request(method, params)
File "brownie/network/middlewares/catch_tx_revert.py", line 24, in process_request
result = make_request(method, params)
File "brownie/network/middlewares/geth_poa.py", line 21, in process_request
return middleware_fn(method, params)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "web3/middleware/formatting.py", line 76, in apply_formatters
response = make_request(method, params)
File "web3/middleware/exception_retry_request.py", line 114, in middleware
return make_request(method, params)
File "web3/providers/rpc.py", line 88, in make_request
raw_response = make_post_request(
File "web3/_utils/request.py", line 49, in make_post_request
response.raise_for_status()
File "requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error: Unauthorized for url: https://speedy-nodes-nyc.moralis.io/<moralis_account>/polygon/mumbai
Here’s what I’m doing to deploy. Any ideas what I’m doing wrong?
Regards,
TJ
from scripts.factory.Utils import get_network
from brownie import accounts, My_Factory
from scripts.factory.F_Account import AccountType
from scripts.deploy_factory import deploy_factory
'''From:
- https://admin.moralis.io/speedyNodes
- https://www.youtube.com/watch?v=CLcGRlcxsbc
assert_added> brownie networks add Polygon moralis_mumbai host='https://speedy-nodes-nyc.moralis.io/<moralis_account>/polygon/mumbai' name='Mumbai (moralis)' chainid=80001 explorer='https://mumbai.polygonscan.com/'
stdout> Brownie v1.17.2 - Python development framework for Ethereum
SUCCESS: A new network 'Mumbai (moralis)' has been added
└─Mumbai (moralis)
├─id: moralis_mumbai
├─chainid: 80001
├─explorer: https://mumbai.polygonscan.com/
└─host: https://speedy-nodes-nyc.moralis.io/<moralis_account>/polygon/mumbai
assert_added> brownie accounts new test_acct_1
assert_added> brownie accounts new test_acct_2
(venv) bash:~/PycharmProjects/Brownie_Minis/NFT_Factory$ brownie accounts new test_acct_1
Brownie v1.17.2 - Python development framework for Ethereum
Enter the private key you wish to add: <metamask_exported_private_key>
Enter the password to encrypt this account with:
SUCCESS: A new account 'gen_acct_1' has been generated with the id 'test_acct_1'
(venv) bash:~/PycharmProjects/Brownie_Minis/NFT_Factory$ brownie accounts new test_acct_2
Brownie v1.17.2 - Python development framework for Ethereum
Enter the private key you wish to add: <metamask_exported_private_key>
Enter the password to encrypt this account with:
SUCCESS: A new account 'gen_acct_2' has been generated with the id 'test_acct_2' '''
#
# pycharm.bash> brownie run scripts/deploy_factory_only_Moralis.py --network moralis_mumbai
def deploy_factory_contract():
# --------- DEPLOY FACTORY CONTRACT ---------
network_type = get_network()
nft_symbol = 'SFI'
AccountType.DAO.set_address(address='gen_acct_1') # test account
AccountType.LICENSOR.set_address(address='gen_acct_2') # test account
nft_factory = deploy_factory(networkType=network_type,
dao_acct=AccountType.DAO,
licensor_acct=AccountType.LICENSOR,
nft_symbol=nft_symbol,
gas_price=875000000
)
print('Factory Deployed!')
# --------- DEPLOY FACTORY CONTRACT ---------
def main():
deploy_factory_contract()