-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathHelloWallet.sol
62 lines (53 loc) · 2.21 KB
/
HelloWallet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* This file was generated by EverDev.
* EverDev is a part of EVER OS (see http://ton.dev).
*/
pragma ton-solidity >= 0.67.0;
pragma AbiHeader expire;
// This is class that describes you smart contract.
contract HelloWallet {
// Contract can have an instance variables.
// In this example instance variable `timestamp` is used to store the time of `constructor` or `touch`
// function call
uint32 public timestamp;
// Contract can have a `constructor` – function that will be called when contract will be deployed to the blockchain.
// In this example constructor adds current time to the instance variable.
// All contracts need call tvm.accept(); for succeeded deploy
constructor() {
// Check that contract's public key is set
require(tvm.pubkey() != 0, 101);
// Check that message has signature (msg.pubkey() is not zero) and
// message is signed with the owner's private key
require(msg.pubkey() == tvm.pubkey(), 102);
// The current smart contract agrees to buy some gas to finish the
// current transaction. This actions required to process external
// messages, which bring no value (henceno gas) with themselves.
tvm.accept();
timestamp = block.timestamp;
}
function renderHelloWorld () public pure returns (string) {
tvm.accept();
return 'helloWorld';
}
// Updates variable `timestamp` with current blockchain time.
function touch() external {
// Skip signature check
// require(msg.pubkey() == tvm.pubkey(), 102);
// Tells to the TVM that we accept this message.
tvm.accept();
// Update timestamp
timestamp = block.timestamp;
}
// Function returns value of state variable `timestamp`
function getTimestamp() public view returns (uint) {
tvm.accept();
return timestamp;
}
// Send specified amount of tokens to the specified address
function sendValue(address dest, uint128 amount, bool bounce) public view {
require(msg.pubkey() == tvm.pubkey(), 102);
tvm.accept();
// It allows to make a transfer with arbitrary settings
dest.transfer(amount, bounce, 0);
}
}