Search code examples
command-line-interfaceblockchainweb3pymultiversxerdpy

transaction generation failed: invalid chain ID (ERDPY)


I'm trying to send a bulk transaction on the elrond devnet but i still have an error :

I'm following this doc -> Click here to see it

The script is working but he give me a log talking about an invalid chain id -> [https://gateway.elrond.com/transaction/send]: {'data': None, 'error': 'transaction generation failed: invalid chain ID', 'code': 'internal_issue'} Transaction sent with nonce 45 and backed up to bon-mission-tx-45.json.

So i've updated my config has show here for the devnet and I still have the same error.

Does somebody have an idea?


Solution

  • You can either set a global setting to reuse the chain-ID without explicitly specifying it in the mxpy tx command, or pass it explicitly. I'll detail below:

    First variant is to run an mxpy config to specify the default proxy or the chain id to use if not specified in the mxpy tx body, like so:

    mxpy config set chainID D
    mxpy config set proxy https://devnet-gateway.multiversx.com
    

    See details here: https://docs.elrond.com/sdk-and-tools/erdpy/configuring-erdpy/#docsNav

    Second variant is to append --chain=$CHAIN_ID to your mxpy tx generation script like this:

    function send-bulk-tx {
      for transaction in "${TRANSACTIONS[@]}"; do
        set -- $transaction
        mxpy --verbose tx new --send --outfile="bon-mission-tx-$NONCE.json" --pem=$PEM_FILE --nonce=$NONCE --receiver=$1 --value="$2$DENOMINATION" --gas-limit=50000 --proxy=$PROXY --chain=$CHAIN_ID
        echo "Transaction sent with nonce $NONCE and backed up to bon-mission-tx-$NONCE.json."
        (( NONCE++ ))
      done
    }
    

    and declare your new variable as CHAIN_ID=D besides the PROXY variable in your .sh file.