You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing with brick, it's common to want to create some accounts via inject, and then use those accounts as parameters to call or query, both for invoking the smart contract and for checking the results.
Currently brick seems to rely on the fact that the account hash is deterministically generated from the account name given. So you have to find out the hash by doing getstate <account_name> after the inject, and then manually copy the generated hash into the rest of the .brick file so that it's hardcoded. For example:
inject user1 10000000
# Now we have to remember user1 has this address:
# Amg25cfD4ibjmjPYbtWnMKocrF147gJJxKy5uuFymEBNF2YiPwzr
deploy user1 0 myContract mycontract.lua
# call addUser with user1 as the first argument
call user1 0 myContract addUser `["Amg25cfD4ibjmjPYbtWnMKocrF147gJJxKy5uuFymEBNF2YiPwzr","User's name","24/10/1990"]`
# query getUserByName and check that it returns user1
query myContract getUserByName `["User's name"]` `{"address":"Amg25cfD4ibjmjPYbtWnMKocrF147gJJxKy5uuFymEBNF2YiPwzr","dateOfBirth":"24/10/1990"}`
If I'm wrong please let me know! If I'm right then this should at least be documented in the README, because it's not completely obvious (IMHO).
However it would be much easier to read and write if the account name identifier could be used instead of the hash, e.g. like this:
inject user1 10000000 # We don't need to know the account address :-)
deploy user1 0 myContract mycontract.lua
# call addUser with user1 as the first argument
call user1 0 myContract addUser `[user1,"User's name","24/10/1990"]`
# query getUserByName and check that it returns user1
query myContract getUserByName `["User's name"]` `{"address":user1,"dateOfBirth":"24/10/1990"}`
The text was updated successfully, but these errors were encountered:
aspiers
added
the
UX
Not bugs or features, but areas where the user/developer experience could be better
label
Feb 13, 2020
When testing with brick, it's common to want to create some accounts via
inject
, and then use those accounts as parameters tocall
orquery
, both for invoking the smart contract and for checking the results.Currently brick seems to rely on the fact that the account hash is deterministically generated from the account name given. So you have to find out the hash by doing
getstate <account_name>
after theinject
, and then manually copy the generated hash into the rest of the.brick
file so that it's hardcoded. For example:If I'm wrong please let me know! If I'm right then this should at least be documented in the README, because it's not completely obvious (IMHO).
However it would be much easier to read and write if the account name identifier could be used instead of the hash, e.g. like this:
The text was updated successfully, but these errors were encountered: