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,370 points
905 views

1 answer to this question.

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
• 69,220 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
889 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
• 26,740 points
524 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
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+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
1,415 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
• 69,220 points
1,335 views
0 votes
1 answer

How to reintialize genesis block in geth ethereum?

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

answered Dec 6, 2018 in Blockchain by Omkar
• 69,220 points
6,314 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP