#brownie has an accounts packagefrom brownie import accounts, config, SimpleStorage#put all the deplyment logic in one fucntion:defdeploy_simple_storage():#local ganache accounts account = accounts[0]#import contract into script: from brownie import <name of contract> simple_storage = SimpleStorage.deploy({"from": account})#interact with smart contract, like remix stored_value = simple_storage.retrieve()#view function, no need transaction - no need accountprint(stored_value)#updating state txn = simple_storage.store(3, {"from":account}) txn.wait(1) updated_stored_value = simple_storage.retrieve()print(updated_stored_value)defmain():deploy_simple_storage()
contract SimpleStorage{uintpublic favNum;structPeople {uint favNum;string name;}/*declare person has People type. (like address, uint)assign people values of 2 & Patrick --> People({})this is the same as --> uint public favNum = 5; People public person = People({favNum: 2, name: "Patrick"});*/People[] public people; mapping(string=>uint) public name2num;functionstore(uint_num) public { favNum = _num;}functionretrieve() publicviewreturns(uint){return favNum;}functionaddPerson(uint_favnum,stringmemory_name) public { people.push(People({favNum: _favnum,name: _name})); name2num[_name] = _favnum;}}