> For the complete documentation index, see [llms.txt](https://yuga.gitbook.io/zkyuga-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuga.gitbook.io/zkyuga-whitepaper/developer-guide/erc721/safetransferfrom.md).

# safeTransferFrom

The `safeTransferFrom` method is a crucial feature within the ERC-721 token standard, particularly notable in the realm of non-fungible tokens (NFTs). This method facilitates the secure transfer of a specific NFT from one Ethereum address to another. The term "safe" in its name underscores its capability to verify whether the receiving address is compatible with ERC-721 tokens, thus mitigating risks associated with transferring tokens to incompatible destinations. Accessible through the `ERC721Instance` object, typically provided by client libraries such as `ZkyugaClient`, this method ensures the safe exchange of NFTs.

### Method Signature

```javascript
async safeTransferFrom(from: string, to: string, tokenId: string, signer: WalletSigner): Promise<TransactionResponse>
```

#### Parameters

| Parameter | Type         | Description                                                                                                                                                                                                  |
| --------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| from      | string       | The Ethereum address initiating the transfer, representing the current owner of the NFT to be sent.                                                                                                          |
| to        | string       | The Ethereum address intended to receive the NFT. This method validates whether the recipient address is compatible with ERC-721 tokens.                                                                     |
| tokenId   | string       | A unique identifier corresponding to the ERC-721 token slated for transfer. Each NFT is distinguished by a distinct `tokenId` within the contract.                                                           |
| signer    | WalletSigner | The entity responsible for authorizing and signing the transaction. Signers are typically derived from various mechanisms such as software or hardware wallets, ensuring transaction integrity and security. |

#### Returns

* A `Promise` resolving to a `TransactionResponse` object, furnishing comprehensive details about the transaction, including its status, transaction hash, and more.

### Usage Example

Start by acquiring an instance of the desired ERC-721 token contract:

```javascript
const erc721 = zkyugaClient.getERC721Instance("your ERC-721 contract address here");
```

Then, utilize the `safeTransferFrom` method to securely transfer the designated NFT:

```javascript
const senderAddress = "0xSenderETHAddress";
const recipientAddress = "0xRecipientTHAddress";
const tokenId = "1011"; // Example token ID
const signer = zkyugaClient.createWalletSigner("your private key");

const transactionResponse = await erc721.safeTransferFrom(senderAddress, recipientAddress, tokenId, signer);
console.log(`Transaction Hash: ${transactionResponse.hash}`);
```

### Notes

* It is imperative to verify that the from address is indeed the current owner of the token specified by tokenId before proceeding with the transfer.
* The `safeTransferFrom` method includes safeguards to prevent transfers to incompatible contract addresses, ensuring the security of the transaction.
* As a best practice, exercise extreme caution when handling private keys. Keep the `signer` secure and avoid exposing private keys in insecure environments.

***
