contracts/test.fc:60:4: error: undefined function key, defining a global function of unknown type
(key, val, flag) = d~dict_set(267, sender_address, "");
^
contracts/test.fc:60:9: error: undefined function val, defining a global function of unknown type
(key, val, flag) = d~dict_set(267, sender_address, "");
^
contracts/test.fc:60:22: error: undefined function d, defining a global function of unknown type
(key, val, flag) = d~dict_set(267, sender_address, "");
^
contracts/test.fc:60:57: error: cannot assign an expression of type () to a variable or pattern of type (??82, ??83, int): cannot unify type (??82, ??83, int) with ()
(key, val, flag) = d~dict_set(267, sender_address, "");

Mar 14, 2023, 9:54 PM
It looks like I am missing something so simple that I have no idea of
Mar 14, 2023, 9:54 PM
You can just use
checker~dict_set(267, sender_address, "");
as the last line.
Mar 15, 2023, 5:01 AM
Cheers this fixed the issue!
What's wrong with it?
I have tried slices and bits and the result is the same the exit code 9
What am I missing
Mar 16, 2023, 12:30 AM
Read 4 bits of flags from in_msg_cell.
Mar 16, 2023, 4:24 AM
Have similar problem even reading the 4 first bits
Mar 16, 2023, 4:40 AM
Also, checker should probably come from contract data, not from cs.
Mar 16, 2023, 4:41 AM
Here is my sender's address getting function:
(slice) parse_sender_address(cell in_msg_full) inline {
var cs = in_msg_full.begin_parse(); ;; cell storage; cell into slice
var flags = cs~load_uint(4); ;; subtract(take away) flags

slice sender_address = cs~load_msg_addr(); ;; get sender address
return sender_address;
}
Sample message:
var msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(addr) ;; sender's address; (ex: "kQDmznN8tOKzSQxHTzMTege2QKFcrCwnkTNRtY2cubGB1IKu"a)
.store_coins(1) ;; amount of nanoton
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1) ;; execution of serialization primitives ends
;;(includes 14 parameters)
.store_slice(message_body)
.end_cell();
When I call the function, I get 2 bits slice
CS{Cell{00da6200736739be5a7159a48623a79989bd03db2050ae561613c899a8dac6ce5cd8c0ea0808000000000000000000000000000000000200000000000030396b51446d7a6e4e38744f4b7a53517848547a4d5465676532514b46637243776e6b544e52745932637562474231494b75} bits: 4..6; refs: 0..0}
Mar 16, 2023, 5:05 AM
Reading 4 bits did not helped. I thought that using cs meant getting the data from the (c)ontract (s)torage or something when you have suggested xd. Also I am not loading or saving it like the other variables that I have. I am just using this function. How to store the addresses on the checker dictionary properly?
code looks like this now and I just have the dictionary right here nowhere else like load data or save data
I still get the error "Exit code 9 underflow"
Mar 16, 2023, 11:52 AM
cs is not magic variable, it just holds what you save there (in your code, slice of in_msg_cell).
Mar 16, 2023, 12:01 PM
cs is an example of bad naming, but it's a shorthand from "cell slice"
Mar 16, 2023, 12:21 PM
How to load and store the dict in the contract? The examples I am able to find does this but does not work for me? Is there an additional step to this? Maybe converting cell to slice or something beforehand?
Mar 16, 2023, 12:27 PM
that looks correct
Mar 16, 2023, 12:27 PM
gives out error cannot unify type cell with slice
Mar 16, 2023, 12:27 PM
are you sure that dict is in your contract's storage when you load it?
oh, because the dict is cell
do it (cell) load_data() {...}
Mar 16, 2023, 12:28 PM
Well I tried that before and did not realize the error was caused by somewhere else. I fixed the others including this, thanks! But now I have a problem about the function that needs to check if an address used the contract before. It is about the inputs and outputs again but I couldn't figure out what's wrong. Here is the function and how I *try* to use it. (checker is the dictionary that I load above)
this gives the error
I did figure this out, it was about the defined variable names on load_data. Was not loading the dict properly.
Mar 16, 2023, 12:48 PM
how can you set address as index if index is defined as int and address is slice?
Mar 16, 2023, 3:57 PM
For dict_set/dict_get?, index is slice.
For udict_set/udict_get?, it's unsigned integer.
And for idict_set/idict_get?, it's signed integer.
Mar 16, 2023, 3:59 PM

© 2024 Draquery.com All rights reserved.