Trying to deploy a simple contract to rinkeby

Viewed 395

I've been trying to deploy a contract to the Rinkeby testnet but nothing seems to happen.

The contract I'm trying to deploy is called simpleStorage.sol which is simple and doesn't rely on any external addresses.

Everything works perfectly on my local ganache cli, so I know the contract itself is fine, but when I run the same deploy script on rinkeby nothing seems to happen and I get the following output in the terminal before having to stop the script after like 1hr+

Thanks in advance.

(base) MacBook-Pro:Lesson5_SimpleStorage_Brownie $ brownie run scripts/deploy.py --network rinkeby
Brownie v1.16.4 - Python development framework for Ethereum

Lesson5SimplestorageBrownieProject is the active project.

Running 'scripts/deploy.py::main'...
Deploying contracts...
Current developer account: 0x45003E..... 
Balance: 0.3

.

from brownie import accounts, config, network, SimpleStorage
import os

def deploy_simple_storage():

    #Method 1: Load account
    account = get_account()
    print("Current developer account:", account)
    print("Balance:", account.balance()/(10**18))
    print("\n\n")

    #Deploy the contract - No need to get the abi e.t.c...
    simple_storage = SimpleStorage.deploy({"from": account})
    print("Contract is deployed.")



def get_account():

    #If network is a development one then take straight from the accounts arrays
    if (network.show_active() == "development"):
        return accounts[0]
    else:
        return accounts.add(config["wallets"]["from_key"])


def main():
    print("Deploying contracts...")
    deploy_simple_storage()

UPDATE: I have even tried to add the account 'manually' via brownie accounts new 0 And changing the account in the deploy.py script to be: account = accounts.load("0")

I have also opened a brownie console on the Rinkeby network and simply tried to transfer eth and that doesn't seem to work either.

$ brownie console --network rinkeby
>>> account = accounts.load("0")
Enter password for "0": 
>>> print(account.balance()/(10**18))
0.4
>>> account.transfer("0xAnotherPublicAddress", "0.1 ether")

I am left waiting for eternity until I have to force quit the execution. Nothing shows up on the Rinkeby blockchain explorer and when I log into the associated infer account it shows there's been 100+ call today.

1 Answers

Since it works with ganache but not with rinkeby, that means:

if (network.show_active() == "development"):
        return accounts[0]

this if statemtent runs correctly for ganache but this one:

else:
    return accounts.add(config["wallets"]["from_key"])

Most likely you have an issue with the config, you are not getting private key of the rinkeby account. in brownie-config.yaml you should have this

wallets:
  from_key: YOUR_RINKEBY_PRIVATE_KEY_HERE
  
Related