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

# setApprovalForAll

The `setApprovalForAll` method for the ERC-1155 token standard provides an ability for an Ethereum address (typically representing a smart contract or another user) to manage multiple token IDs on behalf of the current token holder. By setting this approval, the approved address can transfer tokens on the holder's behalf, facilitating operations like batch transfers or trading on decentralized platforms. The method is embedded within the `ERC1155Instance` object, accessible through the appropriate method of the `ZkyugaClient` or the related library.

## Method Signature

```javascript
async setApprovalForAll(
    to: string,
    approved: boolean,
    signer: WalletSigner
): Promise<TransactionResponse>
```

### Parameters

| Parameter | Type         | Description                                                                           |
| --------- | ------------ | ------------------------------------------------------------------------------------- |
| to        | string       | The Ethereum address that is being granted or revoked access to manage the tokens.    |
| approved  | boolean      | A boolean indicating whether approval is being granted (`true`) or revoked (`false`). |
| signer    | WalletSigner | The wallet signer instance responsible for signing the transaction.                   |

### Returns

* A `Promise` resolving to a `TransactionResponse`, detailing the outcome of the approval transaction.

## Usage Example

First, instantiate the desired ERC-1155 token contract:

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

Then, use the `setApprovalForAll` method to grant or revoke approval:

```javascript
const operatorAddress = "0xF39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
const approvalStatus = true; // Set to false to revoke approval
const signer = zkyugaClient.createWalletSigner("your private key");

const approvalTransaction = await erc1155.setApprovalForAll(operatorAddress, approvalStatus, signer);
console.log(`Approval Transaction Hash: ${approvalTransaction.hash}`);
```

## Notes

* The `setApprovalForAll` method is pivotal for scenarios where an external entity (like a smart contract or a marketplace) needs to execute transactions involving multiple token IDs on behalf of the token holder.
* It's of utmost importance to exercise caution when granting approvals. Ensure you trust the external entity with the management of your tokens, and always be ready to revoke access if necessary.

***
