Skip to content
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
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
"pages": [
"standard/tokens/nft/overview",
"standard/tokens/nft/how-works",
"standard/tokens/nft/how-to-transfer",
"standard/tokens/nft/comparison",
"standard/tokens/nft/cNFT-how-it-works"
]
Expand Down
57 changes: 57 additions & 0 deletions standard/tokens/nft/how-to-transfer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: "NFT: how to transfer"
sidebarTitle: "How to transfer"
---

NFT transfer is an operation specified in [TEP 0062](https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md). Its implementation must comply with this standard,
and NFT item contracts must support the logic described there. The NFT transfer message is
also specified and must comply with the corresponding TL-B scheme. This scheme involves, among other things,

- `forward_amount`: the amount of nanotons to be sent to the destination address;
- `forward_payload`: optional custom data that should be sent to the destination address.

If `forward_amount > 0`, then `forward_payload` must comply with one of the [standard formats](https://github.com/ton-blockchain/TEPs/blob/master/text/0062-nft-standard.md#forward_payload-format).

First, you can use your wallet app with NFTs, just follow the corresponding guides (see [Tonkeeper](https://tonkeeper.helpscoutdocs.com/article/47-how-to-send-nft-to-another-wallet) for an instance).
Or you can do it manually. Below there is an illustrative example:

```typescript
import { WalletContractV5R1, TonClient, Address, toNano } from "@ton/ton";

import { mnemonicToPrivateKey } from "@ton/crypto";

import { AssetsSDK, createApi } from "@ton-community/assets-sdk";

async function main() {
const client = new TonClient({
endpoint: "https://toncenter.com/api/v2/jsonRPC",
});

const your_mnemonic = "put your mnemonic here, ...";
const keyPair = await mnemonicToPrivateKey(your_mnemonic.split(" "));

const wallet = WalletContractV5R1.create({
workchain: 0,
publicKey: keyPair.publicKey,
});

const provider = client.provider(wallet.address);
const sender = wallet.sender(provider, keyPair.secretKey);

const NETWORK = "testnet";
const api = await createApi(NETWORK);

const sdk = AssetsSDK.create({
api,
sender,
});

const NFT_ADDRESS = Address.parse("put your NFT item address");
const nftItem = await sdk.openNftItem(NFT_ADDRESS);

const RECEIVER_ADDRESS = Address.parse("put receiver address");
await nftItem.send(sender, RECEIVER_ADDRESS, { value: toNano(10) });
}

void main();
```