0

when I run brownie run scripts/deploy.py --network rinkeby I get this result:enter image description here

and this is my python code:

from brownie import accounts, config, SimpleStorage, network
def deploy_simple_storage():
 account = get_account()
simple_storage = SimpleStorage.deploy({"from": account})
stored_value = simple_storage.retrieve()
print(stored_value)
transaction = simple_storage.store(15, {"from": account})
transaction.wait(1)
updated_stored_value = simple_storage.retrieve()
print(updated_stored_value)
def get_account():
if network.show_active() == "development":
return accounts[0]
else:
return accounts.add(config["wallets"]["from_key"])
def main():
deploy_simple_storage()

-now this python code should make a state change to a smart contract from 0 to 15 on a rinkbey testnet and there is no error in my python code or in my solidity code and I have created a .env file so brownie could see my private key and my project ID on infura. this is my .env file enter image description here

1 Answer 1

2

dev advocate at Chainstack here!

The first thing I want to mention is that Rinkeby was deprecated about a month ago, so you won't be able to interact with it.

Make sure that you use the Goerli or Sepolia testnet!

Checkout this article about the merge and testnets where you can see which testnets have been deprecated :)

Then here you can find a sample code to deploy and interact with a contract if you need it.

from brownie import accounts, SimpleStorage

def main():
    # fetch the account
    account = accounts[0]

    # deploy contract
    deploy_contract = SimpleStorage.deploy({"from":account})

    # print contract address
    print(f"contract deployed at {deploy_contract}")

    # store a number
    transaction_receipt = deploy_contract.storeNumber(15,{"from":account})

    # wait for transaction confirmation
    transaction_receipt.wait(1)

    # retrieve the number
    retrieved_number = deploy_contract.readNumber()

    # print the retrieved number
    print(f"Number Retrieved : {retrieved_number}")

You can also check this article, where you can find an in depth tutorial about Brownie and how to deploy and test.

Chainstack provides reliable Goerli nodes if you need one:

Set up the endpoint URL

  1. Sign up with Chainstack.
  2. Deploy a node.
  3. View node access and credentials.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.