Ethereum generating genesis Python Syntax

0 votes

I tried to generate the genesis file but get this error:

C:\Python34>python mk_genesis_block.py --extradata 0x11bbe8db4e347b4e8c937c1c837
0e4b5ed33adb3db69cbdb7a38e1e50b1b82fa > genesis_block.json
  File "mk_genesis_block.py", line 293
    print json.dumps(evaluate(), indent=4)
             ^
SyntaxError: invalid syntax

Edit: Here is the surrounding lines:

if __name__ == '__main__':
    print json.dumps(evaluate(), indent=4)

Then it's EOF. The whole file can be viewed here Since the offending line seems to be only output, I commented it and got another error:

C:\Python34>python -tt mk_genesis_block.py --extradata 0x11bbe8db4e347b4e8c937c1
c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa > genesis_block.json
Traceback (most recent call last):
  File "mk_genesis_block.py", line 124, in <module>
    EXTRADATA = (d[2:] if d[:2] == '0x' else d).decode('hex')
AttributeError: 'str' object has no attribute 'decode'

which in conjunction with the other error makes me wonder whether a string instead of a json object is being operated on? Here is the whole arg parsing part:

# Grab the extra data command line argument
if '--extradata' in sys.argv:
    d = (sys.argv+[None])[sys.argv.index('--extradata') + 1]
    EXTRADATA = (d[2:] if d[:2] == '0x' else d).decode('hex')
else:
    EXTRADATA = ''

I also made a test file importing the json package, dumps and decode methods work.

Oct 10, 2018 in Blockchain by slayer
• 29,040 points
17 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

print in python3 is a method not a statement print( "text" ) ... also I believe str.decode was remove in python3 ... instead use codecs.decode(my_str,encoding)

answered Oct 10, 2018 by Omkar
• 65,850 points

Related Questions In Blockchain

+1 vote
1 answer
0 votes
1 answer

Blockchain Python Syntax Error

Look here:  print('Block #{} has been added to ...READ MORE

answered Jul 13, 2018 in Blockchain by Christine
• 15,790 points
41 views
0 votes
1 answer
0 votes
1 answer

Syntax Error running on Python

You are missing the closing parenthesis: hashlib.sha256(self.index + ...READ MORE

answered Sep 21, 2018 in Blockchain by digger
• 27,620 points
10 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
65 views
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points
93 views
0 votes
2 answers

Python syntax error because of version conflicts.

As mentioned in the reply to my ...READ MORE

answered Aug 13, 2018 in Blockchain by Omkar
• 65,850 points
23 views
0 votes
1 answer

How to reintialize genesis block in geth ethereum?

You are getting this error because you ...READ MORE

answered Dec 5, 2018 in Blockchain by Omkar
• 65,850 points
217 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.