4 Aug - 11 Aug 2022 · 16,000 TON

TON Smart Challenge #2

For everybody who is just starting their path of mastering FunC development.
Eusebio Mertz and 179 others
award
TON Smart Challenge #2TON Smart Challenge #2 Winners Trophy

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

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

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

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 = Aexp(-x(B+1/N)), where х - ranking, N - number of participants, A=100 and B=0.005.

Winners of the contest

Join the Community

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

  1. TON Contests channel
  2. TON Dev chat

Participants 180

Did you participate in the activity, too? Sign up to see yourself on the list
avatar
Daniil Sedov 
Developer, Founder, Enthusiast
25 awards
avatar
coalus 
Software Developer
20 awards
avatar
Andrey Kravchenko 
19 awards
loadingloading
loadingloading
loadingloading