Initiating transactions returns FAILURE_WRONG_NETWORK

Hi there!

I’m an developer and experimenting NEM api. In fact I’ve installed the NCC client and created 2 wallets with 0 XEM of each wallet for testing purpose.

Account info request works as expected with url http://localhost:7890/account/get?address=NC7JJ35XVX7QFWW24ZFH5QJFYMAF3W3LB54FUXZO

Sending transaction request with url: http://localhost:7890/transaction/prepare-announce. I’m using Postman Chrome extension for experimenting:

Json object sent to server is

{
 "transaction": {
  "timeStamp": 1455782672,
  "amount": 1000,
  "fee": 30,
  "recipient": "NC7JJ35XVX7QFWW24ZFH5QJFYMAF3W3LB54FUXZO",
  "type": 257,
  "deadline": 9154726,
  "message": {
   "payload": "74657374207472616e73616374696f6e",
   "type": 1
  },
  "version": -1744830463,
  "signer": "my-publickey-is-here"
 },
 "privateKey": "my-privatekey-is-here"
}

and is sent as a body of request (raw and application/json) type. The request is of type POST.

The api document mentions using of requestPrepareAnnounce. But here using postman I didn’t include this param anywhere.

The following is the response:

{
  "innerTransactionHash": {},
  "code": 20,
  "type": 1,
  "message": "FAILURE_WRONG_NETWORK",
  "transactionHash": {
    "data": "1c2742193373bdd7481041a745fa23172829f9ee8ba8352b4c9b84ce85bcfa02"
  }
}

As document states: Entity was rejected because it has the wrong network specified.

This is not clear what is happening. Maybe that is because the wrong usage of Postman.

I’ve also tried my own pc’s ip adress 192.168.143.1 instead of using localhost. In this case the response is:

 {
   "timeStamp": 28283190,
   "error": "Unauthorized",
   "message": "remote 192.168.143.1 attempted to call local /transaction/prepare-announce",
   "status": 401
 }

Maybe that is the case as document states: **The /transaction/prepare-announce API should be **
used only on TRUSTED and LOCAL nodes!

Aka I’m using local node, right? on my own local server (machine).

I’ve also tried to create an android client using HttpUrlConnection to experiment the api. This time I used Content-Type as application/x-www-form-urlencoded or application/json.
and send parameter “requestPrepareAnnounce=” + jsonString; Here jsonString is same as above json object.

The response is same as above:

 {
   "timeStamp": 28283190,
   "error": "Unauthorized",
   "message": "remote 192.168.143.1 attempted to call local /transaction/prepare-announce",
   "status": 401
 }

Attempt with retrofit
> @Headers(“Content-Type: application/json”)

        @POST("transaction/prepare-announce")
        Call<ResponseBody> sendTransaction(@Body TransactionRequest requestPrepareAnnounce);

also returns same response:

    {
      "timeStamp": 28283190,
      "error": "Unauthorized",
      "message": "remote 192.168.143.1 attempted to call local /transaction/prepare-announce",
      "status": 401
    }

So how could I make transaction?

Any help would be appreciated!

As the error message states, you are using the wrong network identifier. The part

“version”: -1744830463,

which is hex 0x98000001 indicates test network. You need to use

“version”: 1744830465,

which is hex 0x68000001 to indicate main network.

NIS does not know that 192.168.143.1 is a local address. But you could add that address in the config.properties:

nis.additionalLocalIps =192.168.143.1

then it should work with that address too.

Thank you very much for your help.

I am also getting same error when I tried to signin with nem and sending some xem to nanowallet!

And I am getting error like FAILURE_WRONG_NETWORK Please suggest me some solution

Can you debug or log what version the $transaction object has?

transaction dump returns me null for version. how to found the version

That is clearly wrong. your $txData probably should supply this (and maybe even more fields for the transaction depending on the implementation of the Transfer class)

Yes may be you can suggest me some API’s which will send transaction from one nem wallet to another ., I tried in many google search still couldnt find solution.

The code is probably using some sdk? Which sdk is it?

nem-php sdk released by evias

use the MosaicTransfer model it will set the version field, check out the unit tests here

please also run phpunit to make sure all is good on your side

to find the version field:

$tx = new MosaicTransfer();
$dto = $tx->toDTO();
$version = dto["transaction"]["version"];

Great help! @gevs thanks

1 Like

Hi @gevs . I have checked version of transaction ., Now I am getting error like ‘FAILURE_TIMESTAMP_TOO_FAR_IN_FUTURE’ . So prblm is with timestamp and deadline hope it so. how to set nem timestamp?

Explained on Telegram. It should be used /time-sync/network-time endpoint