Skip to content

Commit

Permalink
updated ton libs in content
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhsinghcodes committed Aug 29, 2023
1 parent 9ec6c53 commit 3c0270d
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 117 deletions.
14 changes: 7 additions & 7 deletions 01-wallet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ library:npmton
Next, we're going to install a JavaScript package named [ton](https://www.npmjs.com/package/ton) that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:

```console
npm install ton ton-crypto ton-core
npm install @ton/ton @ton/crypto @ton/core
```

---
Expand Down Expand Up @@ -159,7 +159,7 @@ Create the file `step7.ts` with the following content:
network:testnet library:npmton
---
```ts
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand All @@ -184,7 +184,7 @@ main();
network:mainnet library:npmton
---
```ts
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -302,7 +302,7 @@ network:testnet library:npmton
---
```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -335,7 +335,7 @@ network:mainnet library:npmton
---
```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -458,7 +458,7 @@ network:testnet library:npmton
---
```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down Expand Up @@ -516,7 +516,7 @@ network:mainnet library:npmton
---
```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down
14 changes: 7 additions & 7 deletions 02-contract/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This will install the package [func-js](https://github.com/ton-community/func-js
And finally, run in terminal:

```console
npm install ton ton-crypto ton-core
npm install @ton/ton @ton/crypto @ton/core
```

This will install a library that you should be familiar with - [ton](https://www.npmjs.com/package/ton). We'll use it to deploy our contract and interact with it.
Expand Down Expand Up @@ -175,7 +175,7 @@ The recommended way to interact with contracts is to create a small TypeScript c
Use the following code in `counter.ts` to create the initial data cell for deployment:

```ts
import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "ton-core";
import { Contract, ContractProvider, Sender, Address, Cell, contractAddress, beginCell } from "@ton/core";

export default class Counter implements Contract {

Expand All @@ -192,7 +192,7 @@ export default class Counter implements Contract {
}
```

Notice a few interesting things about this TypeScript code. First, it depends on the package [ton-core](https://www.npmjs.com/package/ton-core) instead of [ton](https://www.npmjs.com/package/ton), which contains a small subset of base types and is therefore slower to change - an important feature when building a stable interface for our contract. Second, the code that creates the data cell mimics the FunC API and is almost identical to our `save_data()` FunC function. Third, we can see the derivation of the contract address from the code cell and data cell using the function `contractAddress`.
Notice a few interesting things about this TypeScript code. First, it depends on the package [@ton/core](https://www.npmjs.com/package/@ton/core) instead of [ton](https://www.npmjs.com/package/ton), which contains a small subset of base types and is therefore slower to change - an important feature when building a stable interface for our contract. Second, the code that creates the data cell mimics the FunC API and is almost identical to our `save_data()` FunC function. Third, we can see the derivation of the contract address from the code cell and data cell using the function `contractAddress`.

The actual deployment involves sending the first message that will cause our contract to be deployed. We can piggyback any message that is directed towards our contract. This can even be the increment message with op #1, but we will do something simpler. We will just send some TON coins to our contract (an empty message) and piggyback that. Let's make this part of our interface. Add the function `sendDeploy()` to `counter.ts` - this function will send the deployment message:

Expand Down Expand Up @@ -235,7 +235,7 @@ network:testnet
```ts
import * as fs from "fs";
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, Cell, WalletContractV4 } from "ton";
import Counter from "./counter"; // this is the interface class from step 7

Expand Down Expand Up @@ -297,7 +297,7 @@ network:mainnet
```ts
import * as fs from "fs";
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, Cell, WalletContractV4 } from "ton";
import Counter from "./counter"; // this is the interface class from step 7

Expand Down Expand Up @@ -518,7 +518,7 @@ network:testnet
---
```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, Address } from "ton";
import Counter from "./counter"; // this is the interface class we just implemented

Expand Down Expand Up @@ -572,7 +572,7 @@ network:mainnet
---
```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, Address } from "ton";
import Counter from "./counter"; // this is the interface class we just implemented

Expand Down
8 changes: 4 additions & 4 deletions 03-client/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ npm install
We will need to install a few more packages that will allow us to interact with TON Blockchain. We've seen these packages in action in the previous tutorial. Run the following in terminal:

```console
npm install ton ton-core ton-crypto
npm install @ton/ton @ton/core @ton/crypto
npm install @orbs-network/ton-access
```

Expand Down Expand Up @@ -209,7 +209,7 @@ import { useEffect, useState } from 'react';
import Counter from '../contracts/counter';
import { useTonClient } from './useTonClient';
import { useAsyncInitialize } from './useAsyncInitialize';
import { Address, OpenedContract } from 'ton-core';
import { Address, OpenedContract } from '@ton/core';

export function useCounterContract() {
const client = useTonClient();
Expand Down Expand Up @@ -292,7 +292,7 @@ Create the file `src/hooks/useTonConnect.ts` with the following content:

```ts
import { useTonConnectUI } from '@tonconnect/ui-react';
import { Sender, SenderArguments } from 'ton-core';
import { Sender, SenderArguments } from '@ton/core';

export function useTonConnect(): { sender: Sender; connected: boolean } {
const [tonConnectUI] = useTonConnectUI();
Expand Down Expand Up @@ -327,7 +327,7 @@ import Counter from '../contracts/counter';
import { useTonClient } from './useTonClient';
import { useAsyncInitialize } from './useAsyncInitialize';
import { useTonConnect } from './useTonConnect';
import { Address, OpenedContract } from 'ton-core';
import { Address, OpenedContract } from '@ton/core';

export function useCounterContract() {
const client = useTonClient();
Expand Down
16 changes: 8 additions & 8 deletions docs/01-wallet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ <h2 id="step6setupyourlocalmachineforcoding">Step 6: Set up your local machine f
<pre><code class="console language-console">npm install ts-node
</code></pre>
<p>Next, we're going to install a JavaScript package named <a href="https://www.npmjs.com/package/ton">ton</a> that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:</p>
<pre><code class="console language-console">npm install ton ton-crypto ton-core
<pre><code class="console language-console">npm install @ton/ton @ton/crypto @ton/core
</code></pre>
<h2 id="step7getthewalletaddressprogrammatically">Step 7: Get the wallet address programmatically</h2>
<p>The first thing we'll do is calculate the address of our wallet in code and see that it matches what we saw in the explorer. This action is completely offline since the wallet address is derived from the version of the wallet and the private key used to create it.</p>
<p>Let's assume that your secret 24 word mnemonic is <code>unfold sugar water ...</code> - this is the phrase we backed up in step 2.</p>
<p>Create the file <code>step7.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "ton-crypto";
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -209,7 +209,7 @@ <h2 id="step8readwalletstatefromthechain">Step 8: Read wallet state from the cha
</code></pre>
<p>Create the file <code>step8.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -246,7 +246,7 @@ <h2 id="step9sendtransfertransactiontothechain">Step 9: Send transfer transactio
</video>
<p>Create a new file <code>step9.ts</code> with this content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down Expand Up @@ -562,13 +562,13 @@ <h2 id="step6setupyourlocalmachineforcoding">Step 6: Set up your local machine f
<pre><code class="console language-console">npm install ts-node
</code></pre>
<p>Next, we're going to install a JavaScript package named <a href="https://www.npmjs.com/package/ton">ton</a> that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:</p>
<pre><code class="console language-console">npm install ton ton-crypto ton-core
<pre><code class="console language-console">npm install @ton/ton @ton/crypto @ton/core
</code></pre>
<h2 id="step7getthewalletaddressprogrammatically">Step 7: Get the wallet address programmatically</h2>
<p>The first thing we'll do is calculate the address of our wallet in code and see that it matches what we saw in the explorer. This action is completely offline since the wallet address is derived from the version of the wallet and the private key used to create it.</p>
<p>Let's assume that your secret 24 word mnemonic is <code>unfold sugar water ...</code> - this is the phrase we backed up in step 2.</p>
<p>Create the file <code>step7.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "ton-crypto";
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -599,7 +599,7 @@ <h2 id="step8readwalletstatefromthechain">Step 8: Read wallet state from the cha
</code></pre>
<p>Create the file <code>step8.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -636,7 +636,7 @@ <h2 id="step9sendtransfertransactiontothechain">Step 9: Send transfer transactio
</video>
<p>Create a new file <code>step9.ts</code> with this content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down
8 changes: 4 additions & 4 deletions docs/01-wallet/mainnet-npmton.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ <h2 id="step6setupyourlocalmachineforcoding">Step 6: Set up your local machine f
<pre><code class="console language-console">npm install ts-node
</code></pre>
<p>Next, we're going to install a JavaScript package named <a href="https://www.npmjs.com/package/ton">ton</a> that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:</p>
<pre><code class="console language-console">npm install ton ton-crypto ton-core
<pre><code class="console language-console">npm install @ton/ton @ton/crypto @ton/core
</code></pre>
<h2 id="step7getthewalletaddressprogrammatically">Step 7: Get the wallet address programmatically</h2>
<p>The first thing we'll do is calculate the address of our wallet in code and see that it matches what we saw in the explorer. This action is completely offline since the wallet address is derived from the version of the wallet and the private key used to create it.</p>
<p>Let's assume that your secret 24 word mnemonic is <code>unfold sugar water ...</code> - this is the phrase we backed up in step 2.</p>
<p>Create the file <code>step7.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "ton-crypto";
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -86,7 +86,7 @@ <h2 id="step8readwalletstatefromthechain">Step 8: Read wallet state from the cha
</code></pre>
<p>Create the file <code>step8.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -123,7 +123,7 @@ <h2 id="step9sendtransfertransactiontothechain">Step 9: Send transfer transactio
</video>
<p>Create a new file <code>step9.ts</code> with this content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down
8 changes: 4 additions & 4 deletions docs/01-wallet/mainnet-npmton.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ npm install ts-node
Next, we're going to install a JavaScript package named [ton](https://www.npmjs.com/package/ton) that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:

```console
npm install ton ton-crypto ton-core
npm install @ton/ton @ton/crypto @ton/core
```

## Step 7: Get the wallet address programmatically
Expand All @@ -114,7 +114,7 @@ Let's assume that your secret 24 word mnemonic is `unfold sugar water ...` - thi
Create the file `step7.ts` with the following content:

```ts
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -159,7 +159,7 @@ Create the file `step8.ts` with the following content:

```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -207,7 +207,7 @@ Create a new file `step9.ts` with this content:

```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down
8 changes: 4 additions & 4 deletions docs/01-wallet/testnet-npmton.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ <h2 id="step6setupyourlocalmachineforcoding">Step 6: Set up your local machine f
<pre><code class="console language-console">npm install ts-node
</code></pre>
<p>Next, we're going to install a JavaScript package named <a href="https://www.npmjs.com/package/ton">ton</a> that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:</p>
<pre><code class="console language-console">npm install ton ton-crypto ton-core
<pre><code class="console language-console">npm install @ton/ton @ton/crypto @ton/core
</code></pre>
<h2 id="step7getthewalletaddressprogrammatically">Step 7: Get the wallet address programmatically</h2>
<p>The first thing we'll do is calculate the address of our wallet in code and see that it matches what we saw in the explorer. This action is completely offline since the wallet address is derived from the version of the wallet and the private key used to create it.</p>
<p>Let's assume that your secret 24 word mnemonic is <code>unfold sugar water ...</code> - this is the phrase we backed up in step 2.</p>
<p>Create the file <code>step7.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "ton-crypto";
<pre><code class="ts language-ts">import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -88,7 +88,7 @@ <h2 id="step8readwalletstatefromthechain">Step 8: Read wallet state from the cha
</code></pre>
<p>Create the file <code>step8.ts</code> with the following content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -125,7 +125,7 @@ <h2 id="step9sendtransfertransactiontothechain">Step 9: Send transfer transactio
</video>
<p>Create a new file <code>step9.ts</code> with this content:</p>
<pre><code class="ts language-ts">import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down
8 changes: 4 additions & 4 deletions docs/01-wallet/testnet-npmton.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ npm install ts-node
Next, we're going to install a JavaScript package named [ton](https://www.npmjs.com/package/ton) that will allow us to make TON API calls and manipulate TON objects. Install the package by opening terminal in the project directory and running:

```console
npm install ton ton-crypto ton-core
npm install @ton/ton @ton/crypto @ton/core
```

## Step 7: Get the wallet address programmatically
Expand All @@ -118,7 +118,7 @@ Let's assume that your secret 24 word mnemonic is `unfold sugar water ...` - thi
Create the file `step7.ts` with the following content:

```ts
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4 } from "ton";

async function main() {
Expand Down Expand Up @@ -163,7 +163,7 @@ Create the file `step8.ts` with the following content:

```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { WalletContractV4, TonClient, fromNano } from "ton";

async function main() {
Expand Down Expand Up @@ -211,7 +211,7 @@ Create a new file `step9.ts` with this content:

```ts
import { getHttpEndpoint } from "@orbs-network/ton-access";
import { mnemonicToWalletKey } from "ton-crypto";
import { mnemonicToWalletKey } from "@ton/crypto";
import { TonClient, WalletContractV4, internal } from "ton";

async function main() {
Expand Down
Loading

0 comments on commit 3c0270d

Please sign in to comment.