Skip to content

Onboarding guide: user flow new pt. 2 #1154

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This guide will walk you through reading data from TON Blockchain. You'll learn
- Call `get methods`
- Retrieve account transactions

By the end, you'll understand how to interact with [TON HTTP-based APIs](/v3/guidelines/dapps/apis-sdks/ton-http-apis/). In this guide, [TON Center](https://toncenter.com/) is used—a fast and reliable HTTP API for TON.
By the end, you'll understand how to interact with [TON HTTP-based APIs](/v3/guidelines/dapps/apis-sdks/ton-http-apis). In this guide, [TON Center](https://toncenter.com/) is used—a fast and reliable HTTP API for TON.

## Set up environment

Expand Down Expand Up @@ -57,7 +57,7 @@ Account information includes the `balance`, `state`, `code`, and `data`.
- **Active**: The address is live with code and balance.
- **Frozen**: The address is locked due to insufficient balance for storage costs.
- `code`: The contract's code in raw format.
- `data`: Serialized contract data stored in a [*Cell*](/v3/concepts/dive-into-ton/ton-blockchain/cells-as-data-storage/).
- `data`: Serialized contract data stored in a [*Cell*](/v3/concepts/dive-into-ton/ton-blockchain/cells-as-data-storage).

Account state may be obtained using the [`getContractState`](https://testnet.toncenter.com/api/v2/#/accounts/get_address_information_getAddressInformation_get/) method.

Expand All @@ -74,7 +74,8 @@ async function main() {
endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC',
});

const accountAddress = Address.parse('0QD-SuoCHsCL2pIZfE8IAKsjc0aDpDUQAoo-ALHl2mje04A-'); // Replace with any address
// Replace with any address
const accountAddress = Address.parse('0QD-SuoCHsCL2pIZfE8IAKsjc0aDpDUQAoo-ALHl2mje04A-');

// Calling method on http api
const state = await tonClient.getContractState(accountAddress);
Expand Down Expand Up @@ -127,6 +128,7 @@ async function main() {
const builder = new TupleBuilder();
builder.writeAddress(Address.parse('0QD-SuoCHsCL2pIZfE8IAKsjc0aDpDUQAoo-ALHl2mje04A-'));

// Replace with any address
const accountAddress = Address.parse('kQD0GKBM8ZbryVk2aESmzfU6b9b_8era_IkvBSELujFZPsyy')

// Calling http api to run get method on specific contract
Expand Down Expand Up @@ -232,7 +234,7 @@ A transaction obtained from the API has the following structure:
```
- `address`: The account address where the transaction occurred.
- `utime`: The [unix timestamp](https://www.unixtimestamp.com/) of the transaction.
- `in_msg`: The incoming [message](/v3/documentation/smart-contracts/message-management/messages-and-transactions#what-is-a-message/) that triggered the transaction.
- `in_msg`: The incoming [message](/v3/documentation/smart-contracts/message-management/messages-and-transactions#what-is-a-message) that triggered the transaction.
- `out_msgs`: Outgoing messages sent during the transaction.

### What is a message?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ A common transfer would look like this:
<br></br>

:::caution
Unlike in the [Reading from network](/v3/guidelines/quick-start/blockchain-interaction/reading-from-network/) section, a Toncenter API key is mandatory in the following examples. It may be retrieved using [the following guide](/v3/guidelines/dapps/apis-sdks/api-keys/).
Unlike in the [Reading from the Network](/v3/guidelines/quick-start/blockchain-interaction/reading-from-network/) section, a Toncenter API key is mandatory in the following examples. It may be retrieved using [the following guide](/v3/guidelines/dapps/apis-sdks/api-keys/).
:::

#### Implementation
Expand Down Expand Up @@ -137,15 +137,15 @@ Navigate to [Tonviewer](https://testnet.tonviewer.com/) and paste your address i
## Sending NFTs

[Non-fungible tokens](/v3/guidelines/dapps/asset-processing/nft-processing/nfts/) (NFTs) are assets like a piece of art, digital content, or video that have been tokenized via a blockchain. In TON, NFTs are represented via a collection of smart contracts:
- **NFT Collection**: Stores information about the NFT collection.
- **NFT Item**: Stores information about the NFT item that the user owns.
- **NFT Collection**: stores information about the NFT collection.
- **NFT Item**: stores information about the NFT item that the user owns.

To send an NFT, we should first acquire one. The easiest way to do that is to create and deploy your own NFT through [TON Tools](https://ton-collection-edit.vercel.app/deploy-nft-single). Note that the `owner` addresses of your NFT must be your wallet address to be able to perform operations on it.

The basic operation of the [NFT standard](https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md) in TON is `transfer`. What is actually performed is changing the address of the `owner` in NFT storage to the `new owner`, which is the address of another contract that is now able to perform operations with the `NFT Item`.

:::tip
See [Actors and Roles](/v3/guidelines/quick-start/developing-smart-contracts/processing-messages#actors-and-roles/) for a more conceptual description.
See [Actors and roles](/v3/guidelines/quick-start/developing-smart-contracts/processing-messages#actors-and-roles) for a more conceptual description.
:::

#### Implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ npx blueprint run
```

:::tip
All examples in this guide follow the sequence of these **1-3 steps** with corresponding code samples. **Step 5**, the deployment process, is covered in the last section of the guide: [Deploying to network](/v3/guidelines/quick-start/developing-smart-contracts/deploying-to-network/).
All examples in this guide follow the sequence of these **1-3 steps** with corresponding code samples. **Step 5**, the deployment process, is covered in the last section of the guide: [Deploying to network](/v3/guidelines/quick-start/developing-smart-contracts/func-tolk-folder/deploying-to-network).
:::

Also, you can always generate the same structure for another smart contract if, for example, you want to create multiple contracts interacting with each other by using the following command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Before we proceed to implementation, let's briefly describe the main ways and pa

### Actors and roles

Since TON implements the [actor](/v3/concepts/dive-into-ton/ton-blockchain/blockchain-of-blockchains/#single-actor/) model, it's natural to think about smart contract relations in terms of `roles`, determining who can access smart contract functionality or not. The most common examples of roles are:
Since TON implements the [actor](/v3/concepts/dive-into-ton/ton-blockchain/blockchain-of-blockchains/#single-actor) model, it's natural to think about smart contract relations in terms of `roles`, determining who can access smart contract functionality or not. The most common examples of roles are:

- `anyone`: any contract that doesn't have a distinct role.
- `owner`: a contract that has exclusive access to some crucial parts of the functionality.
Expand All @@ -33,24 +33,24 @@ Let's examine the `recv_internal` function signature to understand how we could
```func
() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure
```
- `my_balance` - smart-contract balance at the beggining of the transaction.
- `my_balance` - smart-contract balance at the beginning of the transaction.
- `msg_value` - funds received with message.
- `in_msg_full` - `cell` containing "header" fields of the message.
- `in_msg_body` - [slice](/v3/documentation/smart-contracts/func/docs/types#atomic-types) containg payload of the message.
- `in_msg_body` - [slice](/v3/documentation/smart-contracts/func/docs/types#atomic-types) containing payload of the message.
</TabItem>
<TabItem value="Tolk" label="Tolk">
```tolk
fun onInternalMessage(myBalance: int, msgValue: int, msgFull: cell, msgBody: slice)
```
- `myBalance` - balance of smart contract at the beggining of the transaction.
- `msgValue` - funds recieved with message.
- `myBalance` - balance of smart contract at the beginning of the transaction.
- `msgValue` - funds received with message.
- `msgFull` - `cell` containing "header" fields of message.
- `msgBody` - [slice](/v3/documentation/smart-contracts/func/docs/types#atomic-types) containg payload pf the message.
- `msgBody` - [slice](/v3/documentation/smart-contracts/func/docs/types#atomic-types) containing payload pf the message.
</TabItem>
</Tabs>

:::info
You can find a comprehensive description of sending messages in this [section](/v3/documentation/smart-contracts/message-management/sending-messages#message-layout/).
You can find a comprehensive description of sending messages in this [section](/v3/documentation/smart-contracts/message-management/sending-messages#message-layout).
:::

What we are specifically interested in is the source address of the message, which we can extract from the `msg_full` cell. By obtaining that address and comparing it to a stored one — we can conditionally allow access to crucial parts of our smart contract functionality. A common approach looks like this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Button from '@site/src/components/button'
If you're stuck on any of the examples, you can find the original template project with all modifications made during this guide [here](https://github.com/ton-community/onboarding-sandbox/tree/main/quick-start/smart-contracts/Example/contracts).
:::

Almost all smart contracts need to store their `data` between transactions. This guide explains standard ways to manage `storage` for smart contracts and how to use `get methods` to access it from outside the blockchain.
Almost all smart contracts need to store their `data` between transactions. This guide explains standard ways to manage `storage` for smart contracts and how to use `get methods` to access it outside the blockchain.

## Smart contract storage operations

Expand Down Expand Up @@ -54,7 +54,7 @@ interface Cell {

## Implementation

Let's modify our smart contract by following the standard steps described in the previous [Blueprint overview](/v3/guidelines/quick-start/developing-smart-contracts/func-tolk-folder/blueprint-sdk-overview/) section.
Let's modify our smart contract by following the standard steps described in the previous [Blueprint overview](/v3/guidelines/quick-start/developing-smart-contracts/func-tolk-folder/blueprint-sdk-overview) section.

### Step 1: edit smart contract code

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ npx blueprint run
```

:::tip
All examples in this guide follow the sequence of these **1-3 steps** with corresponding code samples. **Step 5**, the deployment process, is covered in the last section of the guide: [Deploying to network](/v3/guidelines/quick-start/developing-smart-contracts/tact-folder/tact-deploying-to-network/).
All examples in this guide follow the sequence of these **1-3 steps** with corresponding code samples. **Step 5**, the deployment process, is covered in the last section of the guide: [Deploying to network](/v3/guidelines/quick-start/developing-smart-contracts/tact-folder/tact-deploying-to-network).
:::

Also, you can always generate the same structure for another smart contract if, for example, you want to create multiple contracts interacting with each other by using the following command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,18 @@ You can view it at https://testnet.tonscan.org/address/EQBrFHgzSwxVYBXjIYAM6g2RH
Using `Blueprint` and wallet apps is not the only option. You can create a message with [state_init](/v3/documentation/smart-contracts/message-management/sending-messages#message-layout/) by yourself. Moreover, you can do it even through a smart contract's [internal message](/v3/documentation/smart-contracts/message-management/sending-messages#message-layout/).
:::


## What’s next?
You’ve made it through the guide — great job!
Now, it’s time to dive deeper and keep building. Here are some helpful resources to continue *your Tact journey*:
- [Official website](https://tact-lang.org) - overview, news, and ecosystem links
- [Tact documentation](https://docs.tact-lang.org) — the go-to reference for language features
- [Tact github repo](https://github.com/tact-lang) — source code, issues, and contributions
- [Tact by example](https://tact-by-example.org/all) — hands-on smart contract examples
- [Tact smart battle](https://github.com/ton-studio/tact-smart-battle) — coding challenges to sharpen your skills
- [@tact_kitchen](https://t.me/tact_kitchen) — channel with the latest Tact updates
- [@tactlang](https://t.me/tactlang) — chat for dev discussions and help

Stay curious, build boldly, and don’t hesitate to ask questions — the Tact community is here for you!

<Feedback />
Loading
Loading