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):
self.init(bm=sp.big_map(tkey=sp.TString,tvalue=sp.TString))
@sp.entry_point
def setup(self):
#populate BigMap during setup of contract
pass
@sp.add_test(name="dama")
def test():
contract=contract()
scenario=sp.test_scenario()
scenario+=contract
scenario+=contract.setup()
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
test.eval()
module smartpyio line 25, in eval
self.f()
SmartPy code line 13, in test (line 13)
contract=Contract()
SmartPy code line 5, in __init__ (line 5)
self.init(bm=sp.big_map(tkey=sp.TString,tvalue=sp.TString))
module smartpy line 727, in init
self.setup()
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!