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

Lantstool - FT #2473

Merged
merged 8 commits into from
Feb 18, 2025
Merged
35 changes: 32 additions & 3 deletions docs/2.build/5.primitives/ft.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ import CLICreateToken from "@site/src/components/docs/primitives/ft/near-cli/cre
import SmartContractSendToken from "@site/src/components/docs/primitives/ft/smart-contract/send.md"
import SmartContractAttachTokenToCall from "@site/src/components/docs/primitives/ft/smart-contract/attach-to-call.md"

import CargoNearCreateTokenManually from "@site/src/components/docs/primitives/ft/cargo-near/create-manually.md"

import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel";
import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool";

Besides the native NEAR token, NEAR accounts have access to a [multitude of tokens](https://guide.ref.finance/developers-1/cli-trading#query-whitelisted-tokens) to use throughout the ecosystem. Moreover, it is even possible for users to create their own fungible tokens.

In contrast with the NEAR native token, fungible token (FT) are **not stored** in the user's account. In fact, each FT lives in **their own contract** which is in charge of doing **bookkeeping**. This is, the contract keeps track of how many tokens each user has, and handles transfers internally.
Expand All @@ -56,6 +61,9 @@ You can create an FT using the toolbox on [Dev Portal](https://dev.near.org/tool
<TabItem value="🖥️ CLI" label="🖥️ CLI">
<CLICreateToken />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/create-ft-via-factory.json" />
</TabItem>
</Tabs>

The FT you create will live in the account `<your_token_symbol>.tkn.primitives.near` (e.g. `test.tkn.primitives.near`).
Expand All @@ -70,9 +78,15 @@ On initialization you will define the token's metadata such as its name (e.g. Et

To initialize a FT contract you will need to deploy it and then call the `new` method defining the token's metadata.

```bash
cargo near deploy build-non-reproducible-wasm <account-id> with-init-call new json-args '{"owner_id": "<owner-account>", "total_supply": "1000000000000000", "metadata": { "spec": "ft-1.0.0", "name": "Example Token Name", "symbol": "EXLT", "decimals": 8 }}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' network-config testnet sign-with-keychain send
```
<Tabs groupId="code-tabs">
<TabItem value="🖥️ Cargo-NEAR" label="🖥️ Cargo-NEAR">
<CargoNearCreateTokenManually />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/create-ft-manually.json" />
</TabItem>
</Tabs>


:::tip
Check the [Contract Wizard](https://dev.near.org/contractwizard.near/widget/ContractWizardUI) to create a personalized FT contract!.
Expand All @@ -93,6 +107,9 @@ You can query the FT's metadata by calling the `ft_metadata`.
<TabItem value="🖥️ CLI" label="🖥️ CLI">
<CLIGetMetadata />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/query-ft-metadata.json" />
</TabItem>
</Tabs>

---
Expand All @@ -110,6 +127,9 @@ To know how many coins a user has you will need to query the method `ft_balance_
<TabItem value="🖥️ CLI" label="🖥️ CLI">
<CLICheckBalance />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/check-ft-balance.json" />
</TabItem>
</Tabs>

---
Expand All @@ -129,6 +149,9 @@ By calling this `storage_deposit` the user can register themselves or **register
<TabItem value="🖥️ CLI" label="🖥️ CLI">
<CLIRegister />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/register-user.json" />
</TabItem>
</Tabs>

:::info
Expand All @@ -154,6 +177,9 @@ To send FT to another account you will use the `ft_transfer` method, indicating
<TabItem value="🖥️ CLI" label="🖥️ CLI">
<CLISendToken />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/transfer-tokens.json" />
</TabItem>
<TabItem value="📄 Contract" label="📄 Contract" default>
<SmartContractSendToken />
</TabItem>
Expand All @@ -176,6 +202,9 @@ Let's assume that you need to deposit FTs on Ref Finance.
<TabItem value="🖥️ CLI" label="🖥️ CLI">
<CLIAttachTokenToCall />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/ft/attach-ft-to-call.json" />
</TabItem>
<TabItem value="📄 Contract" label="📄 Contract" default>
<SmartContractAttachTokenToCall />
</TabItem>
Expand Down
35 changes: 15 additions & 20 deletions docs/2.build/5.primitives/linkdrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {FeatureList, Column, Feature} from "@site/src/components/featurelist"
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { Github } from "@site/src/components/codetabs"
import { LantstoolLabel } from '@site/src/components/lantstool/LantstoolLabel/LantstoolLabel';
import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel";
import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool";

Linkdrops allow users to distribute assets and onboard people to Web3 apps through a simple web link.

Expand Down Expand Up @@ -213,9 +214,8 @@ near call v2.keypom.near create_drop '{"public_keys": <PUBLIC_KEYS>, "deposit_pe

</TabItem>

<TabItem value="Lantstool" label={<LantstoolLabel/>}>
<p>Try it out on [Lantstool](https://app.lantstool.dev/import/gh/lantstool/examples.near-protocol/main/docs/2.build/5.primitives/linkdrop/create-near-drop.json)</p>
<Github language="json" url="https://github.com/lantstool/examples.near-protocol/blob/main/docs/2.build/5.primitives/linkdrop/create-near-drop.json" />
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/linkdrop/create-near-drop.json" />
</TabItem>
</Tabs>

Expand Down Expand Up @@ -306,9 +306,8 @@ near call v2.keypom.near create_drop '{"public_keys": <PUBLIC_KEYS>, "deposit_pe

</TabItem>

<TabItem value="Lantstool" label={<LantstoolLabel/>}>
<p>Try it out on [Lantstool](https://app.lantstool.dev/import/gh/lantstool/examples.near-protocol/main/docs/2.build/5.primitives/linkdrop/create-nft-drop.json)</p>
<Github language="json" url="https://github.com/lantstool/examples.near-protocol/blob/main/docs/2.build/5.primitives/linkdrop/create-nft-drop.json" />
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/linkdrop/create-nft-drop.json" />
</TabItem>
</Tabs>

Expand Down Expand Up @@ -372,9 +371,8 @@ near call nft.primitives.near nft_transfer_call '{"receiver_id": "v2.keypom.near

</TabItem>

<TabItem value="Lantstool" label={<LantstoolLabel/>}>
<p>Try it out on [Lantstool](https://app.lantstool.dev/import/gh/lantstool/examples.near-protocol/main/docs/2.build/5.primitives/linkdrop/transfer-nft-to-v2keypomnear.json)</p>
<Github language="json" url="https://github.com/lantstool/examples.near-protocol/blob/main/docs/2.build/5.primitives/linkdrop/transfer-nft-to-v2keypomnear.json" />
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/linkdrop/transfer-nft-to-v2keypomnear.json" />
</TabItem>
</Tabs>

Expand Down Expand Up @@ -467,10 +465,9 @@ near call v2.keypom.near create_drop '{"public_keys": <PUBLIC_KEYS>, "deposit_pe

</TabItem>

<TabItem value="Lantstool" label={<LantstoolLabel/>}>
<p>Try it out on [Lantstool](https://app.lantstool.dev/import/gh/lantstool/examples.near-protocol/main/docs/2.build/5.primitives/linkdrop/create-ft-drop.json)</p>
<Github language="json" url="https://github.com/lantstool/examples.near-protocol/blob/main/docs/2.build/5.primitives/linkdrop/create-ft-drop.json" />
</TabItem>
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/linkdrop/create-ft-drop.json" />
</TabItem>
</Tabs>

#### 2. Transferring FT
Expand Down Expand Up @@ -533,9 +530,8 @@ near call ft.primitives.near ft_transfer '{"receiver_id": "v2.keypom.near", "amo

</TabItem>

<TabItem value="Lantstool" label={<LantstoolLabel/>}>
<p>Try it out on [Lantstool](https://app.lantstool.dev/import/gh/lantstool/examples.near-protocol/main/docs/2.build/5.primitives/linkdrop/transfer-ft-to-v2keypomnear.json)</p>
<Github language="json" url="https://github.com/lantstool/examples.near-protocol/blob/main/docs/2.build/5.primitives/linkdrop/transfer-ft-to-v2keypomnear.json" />
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/linkdrop/transfer-ft-to-v2keypomnear.json" />
</TabItem>
</Tabs>

Expand Down Expand Up @@ -654,9 +650,8 @@ near call v2.keypom.near create_drop '{"public_keys": <PUBLIC_KEYS>, "deposit_pe

</TabItem>

<TabItem value="Lantstool" label={<LantstoolLabel/>}>
<p>Try it out on [Lantstool](https://app.lantstool.dev/import/gh/lantstool/examples.near-protocol/main/docs/2.build/5.primitives/linkdrop/create-function-call-drop.json)</p>
<Github language="json" url="https://github.com/lantstool/examples.near-protocol/blob/main/docs/2.build/5.primitives/linkdrop/create-function-call-drop.json" />
<TabItem value="Lantstool" label={<LantstoolLabel />}>
<TryOutOnLantstool path="docs/2.build/5.primitives/linkdrop/create-function-call-drop.json" />
</TabItem>
</Tabs>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```bash
cargo near deploy build-non-reproducible-wasm <account-id> with-init-call new json-args '{"owner_id": "<owner-account>", "total_supply": "1000000000000000", "metadata": { "spec": "ft-1.0.0", "name": "Example Token Name", "symbol": "EXLT", "decimals": 8 }}' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' network-config testnet sign-with-keychain send
```
Loading