Nem network spam bot

im going to give a shot at making a bot for spamming the network with transactions but im wondering a few things like does matter if the amount being sent or the fee is fixed for all transactions to if it should be variable for every transaction? also how many transactions per min/hour etc would be best for a robust test? im thinking il be able to set up a gang of nodes with a bot on each spittin out transactions like nuts… but how many tx's are too many? obviously i want to test the network but i dont want to bring it crashing down either… ::slight_smile:

edit: na looks like i can do it using the gui and not a clue how to do anything with direct api calls to the nis(i did say i only have basic skills)… :confused: oh well… :frowning:

I would like to give this a shot, can someone please post the API syntax for sending a transaction?

API docummentation will hopefully come during the following week or the week after that.
Doing it over the gui will most likely not allow you to really go nuts. API will facilitate much faster sending.
Amount shouldn't matter but I'd vary with the fee.

So no API is available then? :(  I have a script I used on a different coin I was hoping to adapt for NEM.


So no API is available then? :(  I have a script I used on a different coin I was hoping to adapt for NEM.

Any chance I could get a look at it? Seeing how api calls are used I think will make a massive difference in my understanding.. Are they the same/similar to calling a method and sending a value to that method such as an address/amount?

I would like to give this a shot, can someone please post the API syntax for sending a transaction?


It's probably easiest to use the NCC APIs, which are documented here: https://github.com/NewEconomyMovement/NemCommunityClient/blob/master/docs/api.md. You'll want to look at /wallet/account/transaction/send and /wallet/account/transaction/validate.


I would like to give this a shot, can someone please post the API syntax for sending a transaction?


It's probably easiest to use the NCC APIs, which are documented here: https://github.com/NewEconomyMovement/NemCommunityClient/blob/master/docs/api.md. You'll want to look at /wallet/account/transaction/send and /wallet/account/transaction/validate.
Thank you for the info but is there any way you can give some steps on how to use this?
This is my old script I used:

#!/bin/bash


while :
do
./cryptonited -testnet sendtoaddress myoq946jrvuBCcHwzYV1cQV68Bdw1cVbjd "0.01000000ep"
sleep 1
done



I would like to give this a shot, can someone please post the API syntax for sending a transaction?


It's probably easiest to use the NCC APIs, which are documented here: https://github.com/NewEconomyMovement/NemCommunityClient/blob/master/docs/api.md. You'll want to look at /wallet/account/transaction/send and /wallet/account/transaction/validate.
Thank you for the info but is there any way you can give some steps on how to use this?
This is my old script I used:

#!/bin/bash


while :
do
./cryptonited -testnet sendtoaddress myoq946jrvuBCcHwzYV1cQV68Bdw1cVbjd "0.01000000ep"
sleep 1
done


What's cryptonited ? Some client for another crypto ?




I would like to give this a shot, can someone please post the API syntax for sending a transaction?


It's probably easiest to use the NCC APIs, which are documented here: https://github.com/NewEconomyMovement/NemCommunityClient/blob/master/docs/api.md. You'll want to look at /wallet/account/transaction/send and /wallet/account/transaction/validate.
Thank you for the info but is there any way you can give some steps on how to use this?
This is my old script I used:

#!/bin/bash


while :
do
./cryptonited -testnet sendtoaddress myoq946jrvuBCcHwzYV1cQV68Bdw1cVbjd "0.01000000ep"
sleep 1
done


What's cryptonited ? Some client for another crypto ?
yes, i was helping to do stress testing for it too. It was a mini-blockchain of bitcoin kind of thing.

Some stressing suggestion:  :slight_smile:

amount = 10
fee = 0.1  (or which is minimum for 10 NEM)
TIME_X = 10 sec

for ever? :slight_smile:

  for address in addressList
      send  amount with fee to  address
      pause for TIME_X
  endfor

  amount = amount + 2
  fee = fee + 0.1
  TIME_X = TIME_X - 2 sec
  if TIME_X < 0.1 sec
            TIME_X = 10

endfor


Some stressing suggestion:  :)

amount = 10
fee = 0.1  (or which is minimum for 10 NEM)
TIME_X = 10 sec

for ever? :)

  for address in addressList
      send  amount with fee to  address
      pause for TIME_X
  endfor

  amount = amount + 2
  fee = fee + 0.1
  TIME_X = TIME_X - 2 sec
  if TIME_X < 0.1 sec
            TIME_X = 10

endfor
I'm not sure I follow? How do you run this?


Some stressing suggestion:  :)

amount = 10
fee = 0.1  (or which is minimum for 10 NEM)
TIME_X = 10 sec

for ever? :)

  for address in addressList
      send  amount with fee to  address
      pause for TIME_X
  endfor

  amount = amount + 2
  fee = fee + 0.1
  TIME_X = TIME_X - 2 sec
  if TIME_X < 0.1 sec
            TIME_X = 10

endfor
I'm not sure I follow? How do you run this?


that's just pseudo code :)
He was just proposing a logic.

An example of how to utilize NIS API - which is a REST API - is https://github.com/NewEconomyMovement/blockexplorer/blob/master/api_connectors/async_httpapi.py which is used by the blockexplorer (blockexplorer doesn't need much so the calls you guys would need aren't implemented).
Now this is written to be used async with tornado but the precedure is the same regardles. It's always simple http requests.

Ah ok Pat thanks. Guess we will have to wait for the API to be finished.

Very simple but it works on linux:

<br />echo &quot;TAX3CF5CQVCJEV2DQTQMFBSJN3REPOMH3OZJKP73<br />TA5J37JT6SDUV4K5VYFSLO4XVBGRT5M3LFQMCJJV<br />TBBUSMIV6K57KSRY3I7X42P66SKWDTPEZRFREXOH<br />TACMKSUMO5C64ETLTF33WSDAFT5BHL7K26BOH433<br />TDFW3H62F5DMCYB6MCFPQKOV3PDEVPTOE6GY5RAI<br />TB7RD3F2BUX4DSD4QWH3IHP7PLKBEBAFILHGOOVH&quot; | while read ADDR<br />do<br />nc localhost 8989 &lt;&lt;EOF<br />POST /ncc/api/wallet/account/transaction/send HTTP/1.1<br />Host: localhost<br />Content-type: application/json<br />Content-length: 219<br /><br />{&quot;wallet&quot;:&quot;betatest&quot;,&quot;password&quot;:&quot;beta&quot;,&quot;account&quot;:&quot;TCRIGEL6TUKDGDVBXIVY3HQNADAV6JZMGKNPL23Y&quot;,&quot;recipient&quot;:&quot;$ADDR&quot;,&quot;amount&quot;:10000000,&quot;fee&quot;:2000000,&quot;message&quot;:&quot;&quot;,&quot;encrypt&quot;:0,&quot;hours_due&quot;:12}<br />EOF<br />done<br />

Hey rigel,

So do I run this from my Nem dir?

Alternatively, here is some python code that sends transactions via NCC:

Of course, rigel's shell script is much more compact :D!

<br />import json<br />import sys<br />from time import sleep<br />import datetime<br />import requests<br /><br /><br />class NccConnect:<br />&nbsp; &nbsp; def __init__(self, address, port):<br />&nbsp; &nbsp; &nbsp; &nbsp; self.address = address<br />&nbsp; &nbsp; &nbsp; &nbsp; self.port = port<br /><br />&nbsp; &nbsp; def info_ncc(self):<br />&nbsp; &nbsp; &nbsp; &nbsp; return self.send_get(&#039;info/ncc&#039;)<br /><br />&nbsp; &nbsp; def send_transfer(self, data):<br />&nbsp; &nbsp; &nbsp; &nbsp; return self.send_post(&#039;wallet/account/transaction/send&#039;, data)<br /><br />&nbsp; &nbsp; def send_get(self, path):<br />&nbsp; &nbsp; &nbsp; &nbsp; headers = {&#039;Content-type&#039;: &#039;application/json&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; uri = str.format(&#039;http://{0}:{1}/ncc/api/{2}&#039;, self.address, self.port, path)<br />&nbsp; &nbsp; &nbsp; &nbsp; return requests.get(uri, headers=headers, timeout=10)<br /><br />&nbsp; &nbsp; def send_post(self, path, data):<br />&nbsp; &nbsp; &nbsp; &nbsp; headers = {&#039;Content-type&#039;: &#039;application/json&#039;}<br />&nbsp; &nbsp; &nbsp; &nbsp; uri = str.format(&#039;http://{0}:{1}/ncc/api/{2}&#039;, self.address, self.port, path)<br />&nbsp; &nbsp; &nbsp; &nbsp; return requests.post(uri, data=json.dumps(data), headers=headers, timeout=10)<br /><br /><br />connect = NccConnect(&#039;localhost&#039;, 8989)<br />r = connect.info_ncc()<br />if not r.ok:<br />&nbsp; &nbsp; print(str.format(&#039;unable to query ncc status {0}&#039;, r.status_code))<br />&nbsp; &nbsp; sys.exit()<br /><br />print(str.format(&#039;connected to ncc version {0}&#039;, r.json()&#91;&#039;metaData&#039;]&#91;&#039;version&#039;]))<br /><br /># amounts are in micronem<br />data = {<br />&nbsp; &nbsp; &#039;wallet&#039;: &#039;j&#039;,<br />&nbsp; &nbsp; &#039;password&#039;: &#039;j&#039;,<br />&nbsp; &nbsp; &#039;account&#039;: &#039;TD2T562S4H3XT3QADUYYWEJ4EKJAGUARHGGOLHQQ&#039;,<br />&nbsp; &nbsp; &#039;recipient&#039;: &#039;TALICELCD3XPH4FFI5STGGNSNSWPOTG5E4DS2TOS&#039;,<br />&nbsp; &nbsp; &#039;amount&#039;: 1000000,<br />&nbsp; &nbsp; &#039;fee&#039;: 2000000,<br />&nbsp; &nbsp; &#039;message&#039;: &#039;batch test&#039;,<br />&nbsp; &nbsp; &#039;encrypt&#039;: 1,<br />&nbsp; &nbsp; &#039;hours_due&#039;: 12<br />}<br /><br />time = datetime.datetime.utcnow().time()<br />for i in range(1, 4):<br />&nbsp; &nbsp; print(str.format(&#039;sending transaction {0}&#039;, i))<br />&nbsp; &nbsp; data&#91;&#039;message&#039;] = str.format(&#039;batch test #{0} ({1}Z)&#039;, i, time.strftime(&#039;%H%M%S&#039;))<br />&nbsp; &nbsp; r = connect.send_transfer(data)<br />&nbsp; &nbsp; print(str.format(&#039;send returned {0}&#039;, r.status_code))<br />&nbsp; &nbsp; sleep(1)<br />


Alternatively, here is some python code that sends transactions via NCC:

Of course, rigel's shell script is much more compact :D!

[code]
import json
import sys
from time import sleep
import datetime
import requests


class NccConnect:
    def __init__(self, address, port):
        self.address = address
        self.port = port

    def info_ncc(self):
        return self.send_get('info/ncc')

    def send_transfer(self, data):
        return self.send_post('wallet/account/transaction/send', data)

    def send_get(self, path):
        headers = {'Content-type': 'application/json'}
        uri = str.format('http://{0}:{1}/ncc/api/{2}', self.address, self.port, path)
        return requests.get(uri, headers=headers, timeout=10)

    def send_post(self, path, data):
        headers = {'Content-type': 'application/json'}
        uri = str.format('http://{0}:{1}/ncc/api/{2}', self.address, self.port, path)
        return requests.post(uri, data=json.dumps(data), headers=headers, timeout=10)


connect = NccConnect('localhost', 8989)
r = connect.info_ncc()
if not r.ok:
    print(str.format('unable to query ncc status {0}', r.status_code))
    sys.exit()

print(str.format('connected to ncc version {0}', r.json()['metaData']['version']))

# amounts are in micronem
data = {
    'wallet': 'j',
    'password': 'j',
    'account': 'TD2T562S4H3XT3QADUYYWEJ4EKJAGUARHGGOLHQQ',
    'recipient': 'TALICELCD3XPH4FFI5STGGNSNSWPOTG5E4DS2TOS',
    'amount': 1000000,
    'fee': 2000000,
    'message': 'batch test',
    'encrypt': 1,
    'hours_due': 12
}

time = datetime.datetime.utcnow().time()
for i in range(1, 4):
    print(str.format('sending transaction {0}', i))
    data['message'] = str.format('batch test #{0} ({1}Z)', i, time.strftime('%H%M%S'))
    r = connect.send_transfer(data)
    print(str.format('send returned {0}', r.status_code))
    sleep(1)
[/code]
When I run your script this happens:
connected to ncc version 0.4.9-BETA
sending transaction 1
send returned 400
sending transaction 2
send returned 400
sending transaction 3
send returned 400

I have changed the wallet info to match mine.

Hey rigel,

So do I run this from my Nem dir?


Directory doesn't matter.

You have to change wallet name, wallet password, sending address and content-length (length of the line with brackets).



Hey rigel,

So do I run this from my Nem dir?


Directory doesn't matter.

You have to change wallet name, wallet password, sending address and content-length (length of the line with brackets).
I did that and this is what I am getting:

HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(9.1.z-SNAPSHOT)

5F
{"timeStamp":7248300,"error":"Bad Request","message":"JSON Object was expected","status":400}

0

HTTP/1.1 400 No URI
Content-Length: 0
Connection: close
Server: Jetty(9.1.z-SNAPSHOT)

Has there been a network change to slowdown spamming? My spams are not going out as fast as they were and I'm using the same settings.