# Erc1155

The `Erc1155` class from the `@moonup/moon-api` package provides methods to interact with ERC-1155 tokens.

### Initialization

To use the `Erc1155` class, you need to create an instance of it by passing an instance of the `HttpClient` class to its constructor. The `HttpClient` class is also part of the `@moonup/moon-api` package and provides a convenient way to make HTTP requests.

Here's an example of how to create an instance of the `Erc1155` class:

```javascript
import { HttpClient, Erc1155 } from '@moonup/moon-api';

const http = new HttpClient({
  baseUrl: 'https://beta.usemoon.ai',
  securityWorker: async (securityData) => {
    return {
      headers: {
        Authorization: `Bearer ${securityData.token}`,
      },
    };
  },
});

const erc1155 = new Erc1155(http);
```

### Methods

The `Erc1155` class provides the following methods:

1. `balanceOf(name: string, data: Erc1155Request, params?: RequestParams): Promise<BalanceOfData>`

   * Retrieves the balance of a specific account for a given ERC-1155 token.
   * `name` is a string that represents the name of the ERC-1155 token.
   * `data` is an object of type `Erc1155Request` that contains the necessary information to make the request.
   * `params` is an optional object of type `RequestParams` that can be used to customize the request.
   * Returns a promise that resolves to an object of type `BalanceOfData`.

   Example usage:

   ```javascript
   const name = 'my_token';
   const data = {
     account: 'account_address',
     id: 'token_id',
     contract_address: 'contract_address',
   };
   const result = await erc1155.balanceOf(name, data);
   console.log(result);
   ```
2. `balanceOfBatch(name: string, data: Erc1155Request, params?: RequestParams): Promise<BalanceOfBatchData>`

   * Retrieves the balance of multiple accounts for multiple ERC-1155 tokens.
   * `name` is a string that represents the name of the ERC-1155 token.
   * `data` is an object of type `Erc1155Request` that contains the necessary information to make the request.
   * `params` is an optional object of type `RequestParams` that can be used to customize the request.
   * Returns a promise that resolves to an object of type `BalanceOfBatchData`.

   Example usage:

   ```javascript
   const name = 'my_token';
   const data = {
     accounts: ['account1_address', 'account2_address'],
     ids: ['token1_id', 'token2_id'],
     contract_address: 'contract_address',
   };
   const result = await erc1155.balanceOfBatch(name, data);
   console.log(result);
   ```
3. `isApprovedForAll(name: string, data: Erc1155Request, params?: RequestParams): Promise<IsApprovedForAllData>`

   * Checks if an operator is approved to transfer all tokens of a specific owner.
   * `name` is a string that represents the name of the ERC-1155 token.
   * `data` is an object of type `Erc1155Request` that contains the necessary information to make the request.
   * `params` is an optional object of type `RequestParams` that can be used to customize the request.
   * Returns a promise that resolves to an object of type `IsApprovedForAllData`.

   Example usage:

   ```javascript
   const name = 'my_token';
   const data = {
     account: 'account_address',
     operator: 'operator_address',
     contract_address: 'contract_address',
   };
   const result = await erc1155.isApprovedForAll(name, data);
   console.log(result);
   ```
4. `safeBatchTransferFrom(name: string, data: Erc1155Request, params?: RequestParams): Promise<SafeBatchTransferFromData>`

   * Transfers multiple tokens from one account to another.
   * `name` is a string that represents the name of the ERC-1155 token.
   * `data` is an object of type `Erc1155Request` that contains the necessary information to make the request.
   * `params` is an optional object of type `RequestParams` that can be used to customize the request.
   * Returns a promise that resolves to an object of type `SafeBatchTransferFromData`.

   Example usage:

   ```javascript
   const name = 'my_token';
   const data = {
     from: 'sender_address',
     to: 'recipient_address',
     ids: ['token1_id', 'token2_id'],
     amounts: ['amount1', 'amount2'],
     contract_address: 'contract_address',
   };
   const result = await erc1155.safeBatchTransferFrom(name, data);
   console.log(result);
   ```
5. `safeTransferFrom(name: string, data: Erc1155Request, params?: RequestParams): Promise<SafeTransferFromData>`

   * Transfers a specific token from one account to another.
   * `name` is a string that represents the name of the ERC-1155 token.
   * `data` is an object of type `Erc1155Request` that contains the necessary information to make the request.
   * `params` is an optional object of type `RequestParams` that can be used to customize the request.
   * Returns a promise that resolves to an object of type `SafeTransferFromData`.

   Example usage:

   ```javascript
   const name = 'my_token';
   const data = {
     from: 'sender_address',
     to: 'recipient_address',
     id: 'token_id',
     amount: 'amount',
     contract_address: 'contract_address',
   };
   const result = await erc1155.safeTransferFrom(name, data);
   console.log(result);
   ```
6. `setApprovalForAll(name: string, data: Erc1155Request, params?: RequestParams): Promise<SetApprovalForAllData>`

   * Approves or revokes an operator to transfer all tokens of a specific owner.
   * `name` is a string that represents the name of the ERC-1155 token.
   * `data` is an object of type `Erc1155Request` that contains the necessary information to make the request.
   * `params` is an optional object of type `RequestParams` that can be used to customize the request.
   * Returns a promise that resolves to an object of type `SetApprovalForAllData`.

   Example usage:

   ```javascript
   const name = 'my_token';
   const data = {
     account: 'account_address',
     operator: 'operator_address',
     approved: true,
     contract_address: 'contract_address',
   };
   const result = await erc1155.setApprovalForAll(name, data);
   console.log(result);
   ```

These methods can be used to perform various operations on ERC-1155 tokens, such as checking token balances, approving operators, transferring tokens, and more. The `Erc1155` class is a part of the `@moonup/moon-api` package, which provides a convenient way to interact with the Moon API.

The `contract_address` and `token_id` properties are required for most of the `Erc1155` class methods, as they are used to identify the specific ERC-1155 token contract and token with which to interact. Without the `contract_address` and `token_id` properties, the method may not be able to correctly identify the token contract and token and may return incorrect results.
