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:
Methods
The Erc1155
class provides the following methods:
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 typeErc1155Request
that contains the necessary information to make the request.params
is an optional object of typeRequestParams
that can be used to customize the request.Returns a promise that resolves to an object of type
BalanceOfData
.
Example usage:
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 typeErc1155Request
that contains the necessary information to make the request.params
is an optional object of typeRequestParams
that can be used to customize the request.Returns a promise that resolves to an object of type
BalanceOfBatchData
.
Example usage:
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 typeErc1155Request
that contains the necessary information to make the request.params
is an optional object of typeRequestParams
that can be used to customize the request.Returns a promise that resolves to an object of type
IsApprovedForAllData
.
Example usage:
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 typeErc1155Request
that contains the necessary information to make the request.params
is an optional object of typeRequestParams
that can be used to customize the request.Returns a promise that resolves to an object of type
SafeBatchTransferFromData
.
Example usage:
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 typeErc1155Request
that contains the necessary information to make the request.params
is an optional object of typeRequestParams
that can be used to customize the request.Returns a promise that resolves to an object of type
SafeTransferFromData
.
Example usage:
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 typeErc1155Request
that contains the necessary information to make the request.params
is an optional object of typeRequestParams
that can be used to customize the request.Returns a promise that resolves to an object of type
SetApprovalForAllData
.
Example usage:
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.
Last updated