I would like to setup a smart contract that contains (as defined by smartpy) a BigMap storage.

I have the following code:

import smartpy as sp

class contract(sp.Contract):
  def __init__(self):

  def setup(self):
    #populate BigMap during setup of contract

def test():

This produces the following error in the smartpy.io IDE:

Error: 'AddedMessage' object has no attribute 'contract'

Traceback (most recent call last):

  module smartpyio line 236, in run
  module smartpyio line 25, in eval
  SmartPy code line 13, in test (line 13)
  SmartPy code line 5, in __init__ (line 5)
  module smartpy line 727, in init
  module smartpy line 800, in __call__
   return ExecMessage(self.contract, self.name, params, kargs)

This is clearly related to how SmartPy translate to a Michelson contract. Where am I going wrong? Also, how do I interact with a BigMap in order to populate it when a contract is originated? I would like to fill tkey and tvalue initially and then modify the tvalue through an entry point. How would I go about doing so?

Any help is much appreciated!

1 Answer 1


The first and main issue you have is that setup is a method of class sp.Contract that is broken when you redefine it in your contract. This should not be the case and must be fixed on the SmartPy side. So rename setup anything else and it will work.

A second issue, entry points take two parameters self and params, not just one.

A third issue, contract=contract() is problematic. Don't call everything contract.

You should not worry about types at first but if you wish, what you're doing is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.