My contract should get 2 inputs.
First one must be "1" or "2".
Second one must be how many seconds the contract should stay up.
I need to calculate how many 1's or 2's that has been picked. (Which I have done already)
I need to terminate this contract after the given seconds has passed.
Everything is fine on getting a 1 or 2 and adding them up. And using a get function to get what's the current status.
I am unable to figure out how to get an extra input, in this case "how many seconds" input. And also storing the initial deployment time on the contract.
Mar 11, 2023, 3:33 PM
Is that second input sent by everyone?
If not, you should make your description more precise and clear.
If not, you should make your description more precise and clear.
Mar 11, 2023, 3:34 PM
No it will be set when the contract is deployed for the first time and now that you have mentioned it, the time can be a constant and doesn't need to be given by everyone. But my question on how to get multiple inputs is still valid :)
Mar 11, 2023, 3:36 PM
I recommend you to get familiar with TON's cell concept, then look through contracts working with NFTs (https://github.com/getgems-io/nft-contracts/blob/main/packages/contracts/sources/nft-fixprice-sale-v3.fc) and check if you fully understand them.
Mar 11, 2023, 3:51 PM
Any document suggestion to "get familiar" with the cell concept?
Mar 11, 2023, 4:15 PM
https://ton.org/docs/develop/data-formats/cell-boc#cell
Mar 11, 2023, 4:18 PM
And maybe a contract like a boiler plate or some less code. Instead of this one
Mar 11, 2023, 5:01 PM
You can "store when contract got deployed" by simply placing the required data in contract's StateInit
Mar 11, 2023, 5:02 PM
Let me share the whole code that I have been trying to gather, it is not something spectacular anyways. Where is this contract's StateInit and suggestions for this code.
Mar 11, 2023, 5:04 PM
Remove the 17th line
And also add the storing of contract_time_of_deployment to the 33th line
Mar 11, 2023, 5:05 PM
Like this?
And where to define the contract_time_of_deployment so it gets the time of the deployment?
Mar 11, 2023, 5:07 PM
Don't call the set_data() for the second time - it will just override the previous one.
Instead, store both Total and Time of deployment in the same cell in a single set_data call
Instead, store both Total and Time of deployment in the same cell in a single set_data call
Depends on how do you deploy the contract.
There should be some way to change the contract's data (stateinit)
There should be some way to change the contract's data (stateinit)
Mar 11, 2023, 5:08 PM
I am using toncli and just have this writing "toncli deploy -n testnet".
That goes here
That goes here
And that goes there
Is it the data.fif that I should change
Mar 11, 2023, 5:11 PM
Yep
Mar 11, 2023, 5:11 PM
Well first time seeing this part, looks interesting. Any suggestion on handling this part
Definitely saw this part and read about it but did not think of it
Mar 11, 2023, 5:12 PM
This is Fift.
In short, you need
0 64 u,
?time of deployment? 64 u,
b>
In short, you need
0 64 u,
?time of deployment? 64 u,
b>
Mar 11, 2023, 5:13 PM
In your case, the structure would be like
0 64 u,
12345678 64 u,
b>
Just put the current timestamp instead of 12345678
0 64 u,
12345678 64 u,
b>
Just put the current timestamp instead of 12345678
Mar 11, 2023, 5:13 PM
Well 2 questions since you have just gave me the fish. Should I add the thing you have given me directly at to the bottom and how to get the current timestamp through fif? The first one "0 64 u" is about the counter variable that I have and it is a uint64?
Mar 11, 2023, 5:19 PM
Replace the current from your data.fif with the new one from above
And yes, 0 64 u will be your total which is 64-bit unsigned integer
Mar 11, 2023, 5:21 PM
Should I import something to be able to use this?
Oh wait...
Nope, I still need something that changes dynamically so a timestamp would be perfect
Is this a valid solution to that? Seems pretty wrong, but it deploys. What is the best way to do it?
Mar 11, 2023, 5:38 PM
Yep, that's right
No, just write "now" there
Mar 11, 2023, 5:40 PM
Yep, that did the trick. Thanks, for now 😈
Mar 11, 2023, 5:47 PM
Good luck in learning and buidling)
Mar 11, 2023, 5:48 PM