Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Declaring a contract causes "Requested contract address is not deployed" #329

Closed
ericglau opened this issue Dec 21, 2022 · 2 comments · Fixed by #320
Closed

Declaring a contract causes "Requested contract address is not deployed" #329

ericglau opened this issue Dec 21, 2022 · 2 comments · Fixed by #320
Assignees
Milestone

Comments

@ericglau
Copy link
Member

  1. Create a new project by following the Getting Started steps
  2. Compile the example contract with nile compile
  3. I noticed that I cannot setup an account using setup due to make setup run declare first if needed #299, because the Account contract is not declared yet. So instead, I created a script with the following:
from nile.core.account import Account

async def run(nre):
    signer = "PRIVATE_KEY"
    account = await Account(signer, nre.network)

and ran that script with nile run <script>
4. Try to declare the contract contract with nile declare PRIVATE_KEY contract
5. The following error occurs:

🚀 Declaring contract
⏳ Successfully sent declaration of contract as 0x399998c787e0a063c3ac1d2abac084dcbe09954e3b156d53a8c43a02aa27d35
🧾 Transaction hash: 0x7217575b1175f78ff6201490887019448f5af5e20715e3513aef86d4d168112
📦 Registering 0x399998c787e0a063c3ac1d2abac084dcbe09954e3b156d53a8c43a02aa27d35 in localhost.declarations.txt
⏳ Querying the network for transaction status...
❌ Transaction status: REJECTED
🧾 Found contracts: ['0x01de4967d751b8f23da1129659357191f634c3d451a235d0dd5b2bcb9c7b1ae5:/Users/eric/git/nileproj4/env/lib/python3.9/site-packages/nile/artifacts/Account.json']
⏳ Querying the network with identified contracts...
🧾 Error message:
Requested contract address 0x1de4967d751b8f23da1129659357191f634c3d451a235d0dd5b2bcb9c7b1ae5 is not deployed.

Note that the error message's address 0x1de4967d751b8f23da1129659357191f634c3d451a235d0dd5b2bcb9c7b1ae5 is the same as the account address 0x01de4967d751b8f23da1129659357191f634c3d451a235d0dd5b2bcb9c7b1ae5 but missing a leading 0.


Additional info:

localhost.accounts.json contains:

{
  "0x7e52885445756b313ea16849145363ccb73fb4ab0440dbac333cf9d13de82b9": {
    "address": "0x01de4967d751b8f23da1129659357191f634c3d451a235d0dd5b2bcb9c7b1ae5",
    "index": 0,
    "alias": "PRIVATE_KEY"
  }
}

localhost.deployments.txt contains:

0x01de4967d751b8f23da1129659357191f634c3d451a235d0dd5b2bcb9c7b1ae5:/Users/eric/git/nileproj4/env/lib/python3.9/site-packages/nile/artifacts/abis/Account.json
@martriay
Copy link
Contributor

martriay commented Dec 24, 2022

thanks for reporting this. the devnet is supposed to come with the latest Account interface already declared, maybe they haven't updated it yet.

what happened here is that since the account is not declared, it cannot be deployed nor used for nile functions (nile declare ...). but the real problem is that the deployment process is not properly catching this and registering the account nevertheless. i think this should be resolved with/immediately after the refactor in #320 which will provide a better interface to transaction statuses, including failure.

what you can do in the meantime is to use predeployed accounts:

# script.py
async def run(nre):
  accounts = await nre.get_accounts(predeployed=True)
  declarer_account = accounts[0]
  print(await declarer_account.declare("contract"))

or even declare nile's account contract

async def run(nre):
    accounts = await nre.get_accounts(predeployed=True)
    declarer_account = accounts[0]
    await declarer_account.declare("Account", nile_account=True)

@martriay martriay modified the milestones: next, current Dec 24, 2022
@ericnordelo
Copy link
Member

This issue is fixed as part of #320

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants