Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

«Introduction in FunC» manual is outdated #131

Closed
expectfun opened this issue Jan 17, 2023 · 1 comment
Closed

«Introduction in FunC» manual is outdated #131

expectfun opened this issue Jan 17, 2023 · 1 comment

Comments

@expectfun
Copy link
Contributor

expectfun commented Jan 17, 2023

Describe the bug

The «Introduction in FunC» manual listed on the «Getting Started» page is useful, but there are some outdated parts, grammar mistakes and other issues it would be better to fix.

The manual itself is posted to dev.to/dlvkv and not ton.org/docs so it's really up to its author @dvlkv to update it (and not the TON docs team), I got in contact with him. But since TON docs list that manual among "great approaches to start developing smart contracts" and it's important for the docs to be up-to-date, I post all my suggestions here so it's easier to track the progress for the TON docs team.

Grammar mistakes

  1. «Introduction in FunC»
    It should be «Introduction to FunC»

  2. «developing in TON»
    It sounds like TON is a programming language («developing in Java»). It seems to me it's more correct to say «developing on TON» or «developing using TON» (docs mostly use these ways of saying).

Outdated

  1. «The best way (at the time of writing) to install actual versions of tools is to compile them yourself»

Now there are things like precompiled TON binaries by Tal Kol and the core team. So probably building from the source is not the best way anymore if we talk about the beginners.

  1. «Get some Sandbox coins»

The Tonhub documentation this words links to got outdated and recommends to use a telegram bot @sandbox_faucet_bot, but nowadays @testgiver_ton_bot should be used.

  1. The link to the TON library changed from https://github.com/tonwhales/ton to https://github.com/ton-community/ton (but that's not a huge problem for the manual, it redirects anyway).

  2. There is a more serious problem with actually using that library. It has changed so the code provided in the manual no longer works with new versions. I am not totally sure what is the right approach now but a friend suggested to me a code that worked:

import { Cell, Builder, storeStateInit, contractAddress, StateInit, toNano, beginCell, Address } from 'ton-core';
import { readFileSync } from 'fs';
import qs from 'qs';
import qrcode from 'qrcode-terminal';

// Create a data cell similar to the initial contract state
const dataCell = beginCell()
    .storeUint(0, 32)                        // counter
    .storeAddress(Address.parse('INSERT_ADDRESS'))
    .endCell();

// Load code from build
const codeCell = Cell.fromBoc(readFileSync('./build/hello-world.boc'))[0];

// Calculate address from code & data
const address = contractAddress(0, {
    code: codeCell,
    data: dataCell
});
  
// Prepare init message
const initCell = new Builder();

storeStateInit({
    code: codeCell,
    data: dataCell,
})(initCell);

// Encode link to deploy contract
let link = 'https://test.tonhub.com/transfer/' + address.toString({ testOnly: true }) + '?' + qs.stringify({
    text: 'Deploy contract',
    amount: toNano(1).toString(10),
    init: initCell.asCell().toBoc({ idx: false }).toString('base64')
});

console.log('Address: ' + address.toString({ testOnly: true }));

qrcode.generate(link, { small: true }, (code) => {
     console.log(code)
});

Suggestions to make the manual easier for beginners

  1. «Clone TON monorepo and fetch submodules:
    git clone git@github.com:ton-blockchain/ton.git »

As far as I understand, cloning this way requires the user to be authorised on GitHub via SSH. The tutorial is aimed at beginners who might not have a GitHub account and might not know what SSH is. So I suggest using a version that doesn't require to be logged in:

git clone https://github.com/ton-blockchain/ton

  1. «openssl (can be installed via brew install openssl )», «cmake (XCode build Tools will be ok)»
    The beginners might use Windows and have zero knowledge about brew and XCode so they will just lose time dealing with that before they will find out it is Mac-only. So I suggest adding the words «for macOS» before everything Mac-specific.

  2. I would also suggest adding a word or two about Node.js, Yarn and TypeScript before the part about them. Beginners might not know what any of this means and it would be hard for them to start using Yarn immediately.

Other

  1. I got in trouble with the folder structure. Maybe that is my fault. But it seems to me in the "My common project structure" there is no mention of src/ folder and then it is necessary to have it. Also in the line

#include "../../node_modules/ton-stdlib/func/stdlib.fc"

the "../" part repeats twice, but in my folder structure I only had to move up one level, not sure where this inconsistency came from.

  1. And that one might also be my mistake (I have not got much experience with that), but even though I used the line «OPENSSL_ROOT_DIR=/usr/local/opt/openssl/» as suggested for macOS, I still got the error that OPENSSL_ROOT_DIR is not found.

To reproduce

If you'll try following the manual up to the letter you would find out it no longer works.

Expected behavior

Following the manual should lead to a working smart contract.

Screenshots

No response

Desktop (please complete the following information)

No response

Smartphone (please complete the following information)

No response

Additional context

No response

@reveloper
Copy link
Contributor

@expectfun, thank you for your suggestions. They were helpful for our last 4 weekly updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants