AssetsContractController Actions
17 actions registered.
AssetsContractController:getBalancesInSingleCall
Package: @metamask/assets-controllers
Get the token balance for a list of token addresses in a single call. Only non-zero balances are returned.
Parameters:
| Name | Description |
|---|---|
selectedAddress | The address to check token balances for. |
tokensToDetect | The token addresses to detect balances for. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: The list of non-zero token balances.
Handler signature:
(selectedAddress: string, tokensToDetect: string[], networkClientId?: NetworkClientId) => Promise<BalanceMap>
AssetsContractController:getERC1155BalanceOf
Package: @metamask/assets-controllers
Query for balance of a given ERC 1155 token.
Parameters:
| Name | Description |
|---|---|
userAddress | Wallet public address. |
nftAddress | ERC1155 asset contract address. |
nftId | ERC1155 asset identifier. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'balanceOf'.
Handler signature:
(userAddress: string, nftAddress: string, nftId: string, networkClientId?: NetworkClientId) => Promise<BN>
AssetsContractController:getERC1155Standard
Package: @metamask/assets-controllers
Get a ERC1155Standard instance using the relevant provider instance.
Parameters:
| Name | Description |
|---|---|
networkClientId | Network Client ID used to get the provider. |
Returns: ERC1155Standard instance.
Handler signature:
(networkClientId?: NetworkClientId) => ERC1155Standard
AssetsContractController:getERC1155TokenURI
Package: @metamask/assets-controllers
Query for tokenURI for a given asset.
Parameters:
| Name | Description |
|---|---|
address | ERC1155 asset contract address. |
tokenId | ERC1155 asset identifier. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'tokenURI'.
Handler signature:
(address: string, tokenId: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC20BalanceOf
Package: @metamask/assets-controllers
Get balance or count for current account on specific asset contract.
Parameters:
| Name | Description |
|---|---|
address | Asset ERC20 contract address. |
selectedAddress | Current account public address. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to BN object containing balance for current account on specific asset contract.
Handler signature:
(address: string, selectedAddress: string, networkClientId?: NetworkClientId) => Promise<BN>
AssetsContractController:getERC20Standard
Package: @metamask/assets-controllers
Get a ERC20Standard instance using the relevant provider instance.
Parameters:
| Name | Description |
|---|---|
networkClientId | Network Client ID used to get the provider. |
Returns: ERC20Standard instance.
Handler signature:
(networkClientId?: NetworkClientId) => ERC20Standard
AssetsContractController:getERC20TokenDecimals
Package: @metamask/assets-controllers
Query for the decimals for a given ERC20 asset.
Parameters:
| Name | Description |
|---|---|
address | ERC20 asset contract address. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'decimals'.
Handler signature:
(address: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC20TokenName
Package: @metamask/assets-controllers
Query for the name for a given ERC20 asset.
Parameters:
| Name | Description |
|---|---|
address | ERC20 asset contract address. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'decimals'.
Handler signature:
(address: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC721AssetName
Package: @metamask/assets-controllers
Query for name for a given asset.
Parameters:
| Name | Description |
|---|---|
address | ERC721 or ERC20 asset contract address. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'name'.
Handler signature:
(address: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC721AssetSymbol
Package: @metamask/assets-controllers
Query for symbol for a given asset.
Parameters:
| Name | Description |
|---|---|
address | ERC721 or ERC20 asset contract address. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'symbol'.
Handler signature:
(address: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC721NftTokenId
Package: @metamask/assets-controllers
Enumerate assets assigned to an owner.
Parameters:
| Name | Description |
|---|---|
address | ERC721 asset contract address. |
selectedAddress | Current account public address. |
index | An NFT counter less than balanceOf(selectedAddress). |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'.
Handler signature:
(address: string, selectedAddress: string, index: number, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC721OwnerOf
Package: @metamask/assets-controllers
Query for owner for a given ERC721 asset.
Parameters:
| Name | Description |
|---|---|
address | ERC721 asset contract address. |
tokenId | ERC721 asset identifier. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the owner address.
Handler signature:
(address: string, tokenId: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getERC721Standard
Package: @metamask/assets-controllers
Get a ERC721Standard instance using the relevant provider instance.
Parameters:
| Name | Description |
|---|---|
networkClientId | Network Client ID used to get the provider. |
Returns: ERC721Standard instance.
Handler signature:
(networkClientId?: NetworkClientId) => ERC721Standard
AssetsContractController:getERC721TokenURI
Package: @metamask/assets-controllers
Query for tokenURI for a given ERC721 asset.
Parameters:
| Name | Description |
|---|---|
address | ERC721 asset contract address. |
tokenId | ERC721 asset identifier. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'tokenURI'.
Handler signature:
(address: string, tokenId: string, networkClientId?: NetworkClientId) => Promise<string>
AssetsContractController:getStakedBalanceForChain
Package: @metamask/assets-controllers
Get the staked ethereum balance for multiple addresses in a single call.
Parameters:
| Name | Description |
|---|---|
addresses | The addresses to check staked ethereum balance for. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: The hex staked ethereum balance for address.
Handler signature:
(addresses: string[], networkClientId?: NetworkClientId) => Promise<Record<string, StakedBalance>>
AssetsContractController:getTokenStandardAndDetails
Package: @metamask/assets-controllers
Enumerate assets assigned to an owner.
Parameters:
| Name | Description |
|---|---|
tokenAddress | ERC721 asset contract address. |
userAddress | Current account public address. |
tokenId | ERC721 asset identifier. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to an object containing the token standard and a set of details which depend on which standard the token supports.
Handler signature:
(tokenAddress: string, userAddress?: string, tokenId?: string, networkClientId?: NetworkClientId) => Promise<{
standard: string;
tokenURI?: string | undefined;
symbol?: string | undefined;
name?: string | undefined;
decimals?: string | undefined;
balance?: BN | undefined;
}>
AssetsContractController:transferSingleERC1155
Package: @metamask/assets-controllers
Transfer single ERC1155 token.
Parameters:
| Name | Description |
|---|---|
nftAddress | ERC1155 token address. |
senderAddress | ERC1155 token sender. |
recipientAddress | ERC1155 token recipient. |
nftId | ERC1155 token id. |
qty | Quantity of tokens to be sent. |
networkClientId | Network Client ID to fetch the provider with. |
Returns: Promise resolving to the 'transferSingle' ERC1155 token.
Handler signature:
(nftAddress: string, senderAddress: string, recipientAddress: string, nftId: string, qty: string, networkClientId?: NetworkClientId) => Promise<void>