Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Cannot send raw transaction. #931

Closed
kartava opened this issue Apr 8, 2019 · 4 comments
Closed

Cannot send raw transaction. #931

kartava opened this issue Apr 8, 2019 · 4 comments

Comments

@kartava
Copy link

kartava commented Apr 8, 2019

I'm trying to use this example with my data.

And the following error appears:

{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -504,
    "message": "Block or transaction validation failed."
  }
}

contract_tx.ToJson() result →:

{
  "type": "ContractTransaction",
  "txid": "0xe49f80c0375968dc51e5ea785a9de0590fc2ede289c4eee79e189050bd8cd327",
  "size": 178,
  "version": 0,
  "attributes": [
    {
      "usage": 144,
      "data": "c87823b9fd4c4dcfa79647b968379517"
    }
  ],
  "vout": [
    {
      "n": 0,
      "asset": "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
      "value": "10",
      "address": "ARRDk72dypPm9KqRJLGhJhFtvyAVTK9Dw5"
    },
    {
      "n": 1,
      "asset": "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
      "value": "99998856",
      "address": "AHMzmNbxynX1HUx5J3vDcYfU1bCwSaYVve"
    }
  ],
  "vin": [
    {
      "txid": "0x9e2690583f52ede67410084edf21972802082bcb44694c97b9e5ab5a89efb2cf",
      "vout": 2
    }
  ],
  "sys_fee": "0",
  "net_fee": "0",
  "scripts": []
}
@ixje
Copy link
Member

ixje commented Apr 8, 2019

At first sight it looks like you have not signed your transaction.

@kartava
Copy link
Author

kartava commented Apr 10, 2019

Could you please check example on your network.

It seems that the code in example is not actual.

@jseagrave21
Copy link
Contributor

jseagrave21 commented Apr 11, 2019

@kartava the examples are tested here: https://github.com/CityOfZion/neo-python/blob/master/examples/test_build_raw_transactions.py

On a related note, there is an ongoing project to produce a lightweight SDK API which includes a raw transaction builder class which is fully functional here: https://github.com/jseagrave21/neo-python/blob/raw-transaction-class/neo/Core/TX/RawTransaction.py

Please note, if you are using a private net, you will need to be running NeoScan concurrently and use its endpoint for your selection in Network(). For example, this transaction https://neoscan-testnet.io/transaction/dc25e671476550fe837897522bac6b03f7dd83d8a29fe81a2b36e84ad92b9f7b was created with the script:

from neo.Core.TX.RawTransaction import RawTransaction
import json

tx = RawTransaction()
tx.TXType("Contract")
# note that the default network is testnet so tx.Network() is not needed here
tx.Address("AJ7f4nsBXxTBddgHGyKPjF9n11aK73G3oZ")
tx.AddInputs("neo")
tx.AddOutput("neo", "AMtzvuks9yQnYgqB3scjK53oUWj7i7YZxP", 2)
tx.CalcChange()
tx.Sign("OMITTED", "OMITTED")

txid = tx.GetTXID()
print(txid)
res = tx.ToJson()
print("{}".format(json.dumps(res, indent=4)))
res = tx.GetRawTX()
print(res)

Then it was sent via RPC using "sendrawtransaction".

@kartava
Copy link
Author

kartava commented Apr 17, 2019

Thank you! This example works for me.

@kartava kartava closed this as completed Apr 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants