-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsmc-101.txt
42 lines (25 loc) · 1.18 KB
/
smc-101.txt
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
TON Smart Contracts
Receiving internal messages
When internal message is received by smart contract function recv_internal (id=0) is called
Signature:
() recv_internal(int smc_balance, int msg_value, cell msg, slice msg_body)
Where:
smc_balance - balance of smart contract after crediting the value of the inbound message in nanograms
msg_value - balance of the message in nanograms
msg - serialized message cell
msg_body - message body
SMC Introspection
Highly inspired by
https://eips.ethereum.org/EIPS/eip-165
In order to support Introspection SMC should implement supports_interface method:
(int) supports_interface(int interface)
Which returns true if interface supported.
Interfaces are represented by bitwise XOR of function selectors of interface.
Function selectors:
For GET methods
selector = (crc16(<function_name>) & 0xffff) | 0x10000
(same is used in FunC)
For internal message queries
selector = (crc16(<function_formal_definition>) & 0xffff) | 0x10000
Where function_formal_definition is some sort of definition of query e.g. TL or TL-B
Any Smart Contract supporting introspection should also return true when checked for support of supports_interface method