> 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/erc1155/safetransferfrom.md).

# safeTransferFrom

The `safeTransferFrom` method for the ERC-1155 token standard manages the secure transfer of a specified amount of a token with a given ID from one Ethereum address to another. This method ensures a safe transaction by checking if the receiving address implements the necessary ERC-1155 token receiver interface. The method is encapsulated within the `ERC1155Instance` object, which is available through the appropriate method of the `ZkyugaClient` or the associated library.

## Method Signature

```javascript
async safeTransferFrom(
    from: string,
    to: string,
    id: string,
    amount: string,
    data: string = "0x",
    signer: WalletSigner
): Promise<TransactionResponse>
```

### Parameters

<table><thead><tr><th width="159">Parameter</th><th width="155">Type</th><th>Description</th></tr></thead><tbody><tr><td>from</td><td>string</td><td>The Ethereum address from which the tokens will be transferred.</td></tr><tr><td>to</td><td>string</td><td>The Ethereum address designated to receive the tokens.</td></tr><tr><td>id</td><td>string</td><td>The specific ID of the ERC-1155 token involved in the transfer.</td></tr><tr><td>amount</td><td>string</td><td>The quantity of the token to be transferred for the provided ID.</td></tr><tr><td>data</td><td>string</td><td>Optional additional data or bytes to accompany the transfer; defaults to "0x".</td></tr><tr><td>signer</td><td>WalletSigner</td><td>The wallet signer instance responsible for signing the transaction.</td></tr></tbody></table>

### Returns

* A `Promise` resolving to a `TransactionResponse`, which provides details about the secure transfer transaction.

## Usage Example

First, instantiate the desired ERC-1155 token contract:

```javascript
const erc1155 = zkyugaClient.getERC1155Instance("your ERC-1155 contract address here");
```

Then, initiate the `safeTransferFrom` method with the relevant parameters:

```javascript
const senderAddress = "0xE0F5206BBD039e7b0592d8918820024e2a7437b9";
const recipientAddress = "0x315cbb881Ac891D28F78FFd47A9fe6b0D5a23D86";
const tokenId = "specific-token-id";
const transferAmount = "100";
const dataBytes = "0x";  // Optional data bytes
const signer = zkyugaClient.createWalletSigner("your private key");

const transferTransaction = await erc1155.safeTransferFrom(senderAddress, recipientAddress, tokenId, transferAmount, dataBytes, signer);
console.log(`Transfer Transaction Hash: ${transferTransaction.hash}`);
```

## Notes

* The `safeTransferFrom` method adds an additional layer of security by confirming that the recipient address is capable of receiving ERC-1155 tokens. This helps avoid unintentional loss of tokens.
* Always validate the Ethereum addresses, token ID, and other parameters prior to initiating a transfer to ensure accurate and secure token movement.

***
