TON Smart Challenge #2

The TON Smart Challenge is a contest for FunC developers with a total prize fund over 16,000 TON.

The goal of the contest

The goal of the contest

FunC has a steep learning curve and we want to see more examples of easy and simple contracts with extensive comments and documentation. So the primary goal is to provide an easy-to-enter playground where developers can practice and refine their basic FunC programming skills and maybe receive a prize in Toncoin. Please note that the best submissions will be published on GitHub.

Contest format

Contest format

There will be 5 simple concepts to implement. Concepts are chosen to be easy to understand even for people with no prior experience in FunC or smart contract development.

Each task is scored from 0 to 100 points depending on the number of passed tests.

Each get method execution is limited by 100 000 000 gas units. This limit is high enough that it only rules out infinite loops. Any practical solution, regardless of how optimized it is, will fit.

Bot for receiving submissions is @toncontests_bot. The participant will be able to send solutions and receive the result after a short evaluation delay any number of times, but not more than 5 times per hour. The best solution submitted (with the highest total score among all 5 tasks) will be used to determine the final rank.

The organizers of the competition reserve the right to publish participants solutions with usernames (decided by participants themselves) after the contest.

Gas usage will not affect the ranking. Signatures of all functions described in the task, conditions should not be changed.

Task 1: Greatest common divisor

Write the method that calculates greater common divisor for two integers greater or equal to 1 and less than 1048576.

() recv_internal() { } (int) gcd(int a, int b) method_id { }

Read more
Task 2: Merge hashmaps (dictionaries)

Write the method that merges two hashmaps into one. When keys of hashmaps interesect - values from first hashmap should be used, while discarded key/value pairs should be stored into separate hashmap. Method should return two hashmaps (merged_dict, discared_dict). If any of resulting hashmaps is empty it should be represented by null value. Hashmap key length is 256 bit. Each hashmap has at most 256 elements.

() recv_internal() { } (cell, cell) merge_hashmaps(cell dict1, cell dict2) method_id { }

Read more
Task 3: (De)Serialize to сell

Write the method that checks that cell contains valid message in accordance to repository If message is invalid for any reason - method should return (0, null), otherwise it should return (-1, [slice src, slice dest, int amount] ), where src, dest and amount represents source of the message, destination of the message and attached amount of TONs. If any of those values are not presented (or presented as addr_none slice) in the message cell - they should be substituted with null. It is guaranteed that for all tests any HashmapE datatype in message structure is empty hashmaps (has hme_empty constructor).

() recv_internal() { } (int, tuple) validate_message(cell message) method_id { }

Read more
Task 4: (De)Serialize to сell

Write the methods: a) for serialization of tuple of arbitrary values of different types to Cell b) for deserialization of Cell created by method above to original tuple

serialize method gets as input tuple with arbitrary number of elements from 0 to 128 (both 0 and 128 elements are allowed) and outputs Cell. Elements of the tuple may be null, int, cell, slice, tuple (with the same limitations as original tuple). It is guaranteed that the maximum nesting level of tuples is less than 4 and total number of elements less than 1024. deserialize method gets a cell produced by serialize method and should return origin tuple.

() recv_internal() { } (cell) serialize(tuple values) method_id { } (tuple) deserialize(cell serialized) method_id { }

Read more
Task 5: Address encoder

Write the method that for any valid MsgAddressInt with addr_std constructor (check out the repository) returns the slice that contain ASCII encoded base64url user-friendly bouncable address (without test-only flag), check out the documentation

() recv_internal() { } (slice) encode_address(slice Address) method_id { }

Read more

Prizes & honours

Prizes & honours

Winners of the contest will get prizes nominated in Toncoin — the native cryptocurrency of the TON blockchain, which is also used as a resource for contract execution. Prizes are estimated on the basis that there will be around 500 participants and may be adjusted if we will get significantly more or significantly less solutions. Special attention will be paid to eliminate bots. Places will get prizes in accordance to formula:
P = A*exp(-x*(B+1/N)), where х - ranking, N - number of participants, A=100 and B=0.005.

Winners of the сontest

Winners of the сontest

Place

Username

Score

Prize

1
Tindarid
500
190 + 500
1
BorMor
500
190 + 300
1
octechnics/6b75fc55-b8af-5105-9932-283525095768
500
190 + 200 + 30
1
admiral_karkar
500
190 + 100
1
pyAndr3w
500
190 + 400 + 30
1
Stanislav Povolotsky
500
190 + 100
1
noone
500
190
1
darkkcyan
500
190
1
crazyministr
500
190 + 100
1
nocriz
500
190 + 30
1
Gusarich
500
190 + 250
1
moadib
500
190
1
klim0v
500
190
1
denull
500
190
1
XaBbl4
500
190 + 30
1
Cobakka
500
190
1
mrboorger
500
190 + 50
1
@monnttes
500
190
1
stardust
500
190
1
️edudukin
500
190
1
kosrk
500
190
1
nns2009 | Igor Konyakhin
500
190
1
enikesha
500
190
1
NZT
500
190
1
Dong
500
190 + 30
1
receed
500
190
27
donjaron777
495
145
28
narco1eptic
486
143
29
stuxjkee
466
142
30
NO
451
140
31
a desirable username
450
139
31
rsj
450
139
31
wildstyl3r
450
139
31
mastooram
450
139
31
GSA05
450
139
31
vonavi
450
139
37
maxrr_
444
130
38
Arsenicum12
429
129
39
Ant16
420
128
39
Eugene40a
420
128
41
max_martynov
400
125
41
GhazalKazemi1998
400
125
43
nonam3e
394
122
44
Evgeny E
389
121
45
@trinketer22
380
120 + 30
46
chernovArs
359
119
47
vladimirtamara
355
117
48
flypew
350
116
49
R0m4n
340
115
49
d0rm1k
340
115
51
Piteryo
330
113
52
Modest Dolphin
321
111
53
overtired
300
110
53
arseny
300
110
53
thainik
300
110
53
tanya-creator
300
110
53
imtabako
300
110
58
behrang
294
105
58
JeffreyLC
294
105
58
Maxxi
294
105
58
zile
294
105
58
fjolne
294
105
63
zw
290
99
64
maxsimych
289
98
65
dsx
278
97
66
triangolooo
272
96
66
zvero60y
272
96
68
Shayan.To
266
94
69
azrael
265
93
70
Zalupa Konya
262
92
71
BunnyC
260
91
72
Konstantin Klyuchnikov | @knstntn_asuoki
257
90
73
aliravan
252
89 + 30
73
smirnoffkin
252
89
75
flag10
250
87
75
polka125
250
87
75
Virv
250
87
75
Vasilisa Gricocyeva
250
87
75
@SmartCoder_0
250
87
75
george
250
87
75
fme
250
87
75
littlefall
250
87
83
sulatskovalex
249
80
84
gultai4ukr
244
80
85
temazzz
226
79
86
aedobrynin
225
78
87
ser398
222
77
88
tikerlade
221
76
88
panzuwagen
221
76
90
ihorb
216
75
91
ivzakharov
211
74
92
ontawho
205
73
93
velkonost
201
72
93
andreyyurin
201
72
93
Crypto Maine Coon
201
72
93
PeskovMustaches
201
72
97
Igorfardoc
200
69
97
NKuznetosv
200
69
97
wselfjes
200
69
97
alina-erokhina
200
69
97
pantemon
200
69
97
AlbertoTDNeto
200
69
97
Saeed.Odak
200
69
97
@elnikovs
200
69
97
Andy Russo
200
69 + 30
97
Splish_Splash
200
69
97
kingsfoill
200
69
97
creatorAnastasia
200
69
97
vox
200
69
97
dimazhornyk
200
69
97
@thekiba
200
69
97
falcon-feather
200
69
97
Qzarov
200
69
97
robertoarmando
200
69
97
cat
200
69
97
vadim777
200
69
97
L Neres
200
69
97
DmitrijCode
200
69
97
FarAwayyFromHere
200
69
97
golova
200
69
97
jusikX
200
69
97
mmx86
200
69
97
Amin0x443
200
69
124
WayLander
190
52
125
GoodWolf
187
52
126
BelieveYourDream
185
51
126
LovelyEther
185
51
126
MexaHIK
185
51
129
seriouzly
155
50
130
Valera_Grinenko
150
49
130
jannis756
150
49
130
romanychev
150
49
130
vshemm
150
49
134
atread
136
47
135
available3124
135
47
135
PastDream
135
47
135
della
135
47
135
hel O world
135
47
140
imyster1o
130
44
140
psydvl
130
44
142
ArseniyTheParrot
115
43
142
smehnov
115
43
144
elis_alech
105
42
144
AlexLim78
105
42
144
Siddharth
105
42
147
RinRi
100
41
147
spike1236
100
41
147
Youssef El Shabrawii
100
41
147
XIN11
100
41
147
Niko919
100
41
147
truecarry
100
41
147
Visible1
100
41
147
miklemouse
100
41
147
karfly
100
41
147
psylopunk
100
41
147
leoriether
100
41
147
Denis Dvoretskiy
100
41
147
Everule
100
41
147
k_dizzled
100
41
147
makroz
100
41
147
Antony
100
41
147
belliavesha
100
41
147
nescampos
100
41
147
NickFromBSU
100
41
147
altershaman
100
41
147
dogIsuper
100
41
147
Mansurbek
100
41
147
liqwake
100
41
147
AntonIX
100
41
147
ihatecrypto
100
41
147
jorra
100
41
147
dwalkerr
100
41
147
desired-username-in-public-list
100
41
147
mishania2005
100
41
147
dersik
100
41
177
aleksv
95
30
178
mariocynicys
80
30
179
ThreeJ
75
30
180
Meress
50
29
181
vegan-cat
40
29

Bonuses for the best solution of #2, #3, #4, and #5 tasks were awarded to crazyministr, SpyCheese, Arsenicum12, and pyAndr3w correspondingly. Bonuses for the correct solution in the case of non-standard address for task #3 were awarded to SpyCheese, pscvn, otov4its, and YellowCataclysm.

Join the Community

Join the Community

Join community of developers interested in building on TON, from general FunC programming language chat group to TON Contests channel.