Skip to content

move-ton/ticktimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository for freeton contest for running this contract you need: solc, tvm_linker, tonos-cli

Deploy

Compile contract:
solc main.sol
Compile in tvc:
tvm_linker compile --lib stdlib_sol.tvm --abi-json main.abi.json main.code
Generate address
tonos-cli genaddr <main>.tvc main.abi.json --genkey timer.keys.json
Send some crystal there or use giver
Use it!
tonos-cli call <address> createTimer '{"_payload":"<payload in int64>","_time":<time in seconds>}' --abi main.abi.json --sign timer.keys.json

or

tonos-cli call <address> createHandler '{"_payload":"<payload in int64>","_time":<time in seconds>}' --abi main.abi.json --sign timer.keys.json

Are there any differences between createTimer and createHandler?

Yes, createTimer create handler nowtime + your time. Its useful for users. And createHandler set only your time.

How connect this library to my contract?

Its simple. You can watch the test.sol

First you need create contract interface
contract timer {
    function createHandler(uint _payload,uint64 _time) public {}
    function createTimer(uint _payload,uint64 _time) public {}
}
More you need to save address of timer in contract
address timerAddress;
and set this address through the function for example changeAddress
function changeAddress(address _adr) public onlyOwnerAndAccept {
    timerAddress = _adr;
}
Then you need to create handler there will be sending from timer
function _timer_handler(uint payload) public {
    require(timerAddress == msg.sender,100,'Unauthorized');
    <Your code>
}
And start timer
timer(timerAddress).createTimer(100,60);

You can use payload to diffent things, for instance delay send.

By commaster1