Protocole
Protocole

Reputation: 91

Bad request when deploying smart contract

So I'm currently trying to deploy a router smart contract. I've been building it through erdpy contract build, which has been successful (I'm on rust nightly tool chain as the Smart contract needs it). And I am now trying to deploy it, but I can't manage to do it. I keep having a 400 BadRequest from https://devnet-api.elrond.com/transaction/send.

Here are the logs from the deployment:

erdpy contract deploy
INFO:accounts:Account.sync_nonce()
INFO:accounts:Account.sync_nonce() done: 0
INFO:cli.contracts:Contract address: erd1qqqqqqqqqqqqqpgqzqv7kk893c3ftwgaekvvv9whpqcfn4kazqxq3mud36
INFO:transactions:Transaction.send: nonce=0
CRITICAL:cli:Proxy request error for url [https://devnet-api.elrond.com/transaction/send]: {'statusCode': 400, 'message': 'Bad Request'}

And here is erdpy.json used to configure the command:

{
    "configurations": {
        "default": {
            "proxy": "https://devnet-api.elrond.com",
            "chainID": "D"
        }
    },
    "contract":{
        "deploy":{
            "verbose": true,
            "bytecode": "output/router.wasm",
            "recall-nonce": true,
            "nonce": 1,
            "pem": "../../../wallets/owner/wallet-owner.pem",
            "gas-limit": 600000000,
            "send": true,
            "outfile": "deploy-testnet.interaction.json"
        }
    }
}

The contract I'm trying to deploy is the following. I've also been through the OpenAPI Spec or the documentation searching for an answer, but there is nothing about it. This route is normally returning error message, but for this specific case it is not.

Some other contract like ping-pong are working properly with the same erdpy.json config.

Upvotes: 3

Views: 786

Answers (4)

Quentin Diebold
Quentin Diebold

Reputation: 1

In the suggested erdpy.json from Elrond Docs there is an "chainID": "D" variable inside configuration.default object.

Delete this and add inside contract.deploy this : "chain": "D".

Example

{
  "configurations": {
    "default": {
      "proxy": "https://devnet-api.elrond.com"
      "chainID": "D" <----- Delete this
    }
  },
  "contract":{
    "deploy":{
      <Other fields>
      "chain": "D" <----- Add this
    }
  }
}

Upvotes: 0

Stu
Stu

Reputation: 4150

I was getting the "bad request" error too, and I worked out that for me this was because my wallet was empty. To add xEGLD to your devnet wallet:

  1. Go to https://devnet-wallet.elrond.com/faucet
  2. Log in using your pem file / whatever you normally use to log in
  3. Click the "Faucet" option from the left hand menu
  4. This should pop up a modal to add 10 xEGLD to your wallet (You can request 10 xEGLD every 24 hours)
  5. Now you can return to the terminal and run erdpy contract deploy

This worked for me, and now I'm getting the correct output.

Upvotes: 0

Protocole
Protocole

Reputation: 91

After talking with someone who were interested into this issue, I ended up with the following command:

erdpy --verbose contract deploy --project=$PROJECT_NAME --pem="wallet-owner.pem" --gas-limit=600000000 --proxy="https://devnet-gateway.elrond.com" --outfile="elrond.workspace.json" --recall-nonce --send --chain="D"

Replace $PROJECT_NAME by the folder of your contract (you need to be one level upper than your smart contract folder).

It won't use the elrond.json file, but i guess you can move up the file to make the command use it.

Upvotes: 2

Fargerik
Fargerik

Reputation: 210

I have you tried to deploy with the argument --verbose?

That should be something like that (not sure of the syntax because I am on phone) erdpy --verbose contract deploy

Upvotes: 1

Related Questions