-1
Traceback (most recent call last):
  File "C:\Users\RAC\crypto\...\blockchain.py", line 178, in <module>
    blockchain = Blockchain()
                 ^^^^^^^^^^^^
  File "C:\Users\RAC\crypto\...\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

CrazyChucky
  • 3,263
  • 4
  • 11
  • 25
  • 1
    What do you intend the `0` in `self.create_genesis_block(0)` to mean? How should your code know to handle the argument you've supplied? – CrazyChucky Jan 19 '23 at 00:41
  • (Also, welcome to Stack Overflow! Good places to start are the [tour] and [ask]. Please also read about what we expect of a [MRE] when looking for debugging help.) – CrazyChucky Jan 19 '23 at 00:43
  • thank you but what do you mean? im sorry ive been using an ai to help me create this code im about to launch so i need all the help i can get – jreyes2563 Jan 19 '23 at 01:56
  • ...Well, that's alarming. – CrazyChucky Jan 19 '23 at 02:44

2 Answers2

0

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)
  • Thank you this helped and all i had to do was remove the coin part as well and kept the second block_num to 0 – jreyes2563 Jan 19 '23 at 01:55
-1

when you use the self constructor, you need to initialize the class, try

instanse = Blockchain()
instanse.create_genesis_block()