I am coding a script to deploy smart contracts using python web3, and I came across this error when I ran the script:

ValueError: {'message': 'Returned error: project ID does not have access to archive state', 'code': -32000, 'data': {'stack': 'Error: Returned error: project ID does not have access to archive state\n    at Object.ErrorResponse (C:\\Users\\USR1337\\AppData\\Roaming\\npm\\node_modules\\ganache-cli\\build\\ganache-core.node.cli.js:55:2110625)\n    at a (C:\\Users\\USR1337\\AppData\\Roaming\\npm\\node_modules\\ganache-cli\\build\\ganache-core.node.cli.js:55:2108932)\n    at C:\\Users\\USR1337\\AppData\\Roaming\\npm\\node_modules\\ganache-cli\\build\\ganache-core.node.cli.js:55:2093154\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)', 'name': 'Error'}}

deploy.py :

from smart_contracts.solc_compile import compile_contract
from web3 import Web3
import json

# compilation process

compiler = "solc0.8.0.exe"
path = "contracts/"
contract = "inbox.sol"
to = "compiled/"

[abi_path, bytecode_path] = compile_contract(compiler=compiler, path=path, contract=contract, to=to)
with open(abi_path, 'r') as abi_p:
    abi = json.loads(abi_p.read())
with open(bytecode_path, 'r') as bytecode_p:
    bytecode = bytecode_p.read()

# initialize web3 instance
w3 = Web3(Web3.HTTPProvider(''))

# initialize hdwallet (used later for calling contracts with non-view functions
# wallet = w3.eth.account.from_mnemonic(config['SEED'])

# test wallet - needs to be changed each time I set up ganache-cli
wallet = w3.eth.account.from_key("0xe7204334c48885bfce786af6b2532ae445f9bcac249f7080363d86e6356064b7")
w3.eth.defaultAccount = wallet.address


contract_skeleton = w3.eth.contract(abi=abi, bytecode=bytecode)
tx_hash = contract_skeleton.constructor('HI').transact()
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)

contract_reference = w3.eth.contract(

print("Contract Address: " + tx_receipt.contractAddress)
print("Account Balance: " + w3.eth.getBalance(wallet.address))


import subprocess

# compiler should be "solc0.8.0.exe", path should be contracts/, and contract the basename of the contract file
# after compilation returns the file location of the abi and of the binary
def compile_contract(compiler, contract, path, to):
    subprocess.call('{compiler} -o {to} --abi --bin --overwrite {contract}'
                    .format(compiler=compiler, path=path, contract=path + contract, to=to), shell=True)
    return [to + contract.rsplit('.', 1)[0] + '.abi', to + contract.rsplit('.', 1)[0] + '.bin']

# Example: output => ['compiled/inbox.abi', 'compiled/inbox.bin']
# compile_contract("solc0.8.0.exe", "contracts/", "inbox.sol")

I'm using ganache-cli for my test network and I have forked the mainnet through an infura node, and for the most part it seemed to work and my account does have ether. What does this error mean and how do I fix it?

Edit: I have since closed my project and the test-netwrok, and I opened it again and suddenly the code worked (except the last line because I forgot to convert from wei to string, but that wasn't the issue) I would still like to hear if someone has a clue why I got that error before

2 Answers 2


I got this error because I leave it running for too long. So I decided to change the command I'd used before

ganache-cli --fork https://mainnet.infura.io/v3/{PROJECT-ID}@{BLOCK}


ganache-cli --fork https://mainnet.infura.io/v3/{PROJECT-ID}


I can't add much to this, except, that this also fixed the issue for me. The same solution was also suggested here:

Try restarting your ganache-cli of the forked chain. If you leave it >running for too long this issue may come up.

If that doesn't work, and you're using Cloudflare as an HTTP provider, >try using a different HTTP provider, like Infura.io.

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.