Traceback (most recent call last): File "C:UsersRACcrypto...blockchain.py", line 178, in <module> blockchain = Blockchain() ^^^^^^^^^^^^ File "C:UsersRACcrypto...blockchain.py", line 49, in __init__ self.chain = [self.create_genesis_block(0)] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Blockchain.create_genesis_block() takes 1 positional argument but 2 were given
with code looking like this
class Blockchain: def __init__(self): self.chain = [self.create_genesis_block(0)] self.difficulty = 4 self.nodes = dict() self.replicated_nodes = dict() self.coin_ledger = dict() def create_genesis_block(self): return Block("Genesis Block", "0", coin)
ive tried adding other arguments but as i am new to this, i havent been able to figure it out myself properly
Advertisement
Answer
def create_genesis_block(self):
doesn’t take a parameter, maybe you meant:
def create_genesis_block(self, block_num): return Block("Genesis Block", block_num, coin)
or
@staticmethod def create_genesis_block(block_num): return Block("Genesis Block", block_num, coin)