Skip to main content

AssetsContractController Actions

17 actions registered.

NameDeprecated
getBalancesInSingleCall
getERC1155BalanceOf
getERC1155Standard
getERC1155TokenURI
getERC20BalanceOf
getERC20Standard
getERC20TokenDecimals
getERC20TokenName
getERC721AssetName
getERC721AssetSymbol
getERC721NftTokenId
getERC721OwnerOf
getERC721Standard
getERC721TokenURI
getStakedBalanceForChain
getTokenStandardAndDetails
transferSingleERC1155

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:

NameDescription
selectedAddressThe address to check token balances for.
tokensToDetectThe token addresses to detect balances for.
networkClientIdNetwork 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:

NameDescription
userAddressWallet public address.
nftAddressERC1155 asset contract address.
nftIdERC1155 asset identifier.
networkClientIdNetwork 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:

NameDescription
networkClientIdNetwork 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:

NameDescription
addressERC1155 asset contract address.
tokenIdERC1155 asset identifier.
networkClientIdNetwork 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:

NameDescription
addressAsset ERC20 contract address.
selectedAddressCurrent account public address.
networkClientIdNetwork 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:

NameDescription
networkClientIdNetwork 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:

NameDescription
addressERC20 asset contract address.
networkClientIdNetwork 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:

NameDescription
addressERC20 asset contract address.
networkClientIdNetwork 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:

NameDescription
addressERC721 or ERC20 asset contract address.
networkClientIdNetwork 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:

NameDescription
addressERC721 or ERC20 asset contract address.
networkClientIdNetwork 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:

NameDescription
addressERC721 asset contract address.
selectedAddressCurrent account public address.
indexAn NFT counter less than balanceOf(selectedAddress).
networkClientIdNetwork 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:

NameDescription
addressERC721 asset contract address.
tokenIdERC721 asset identifier.
networkClientIdNetwork 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:

NameDescription
networkClientIdNetwork 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:

NameDescription
addressERC721 asset contract address.
tokenIdERC721 asset identifier.
networkClientIdNetwork 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:

NameDescription
addressesThe addresses to check staked ethereum balance for.
networkClientIdNetwork 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:

NameDescription
tokenAddressERC721 asset contract address.
userAddressCurrent account public address.
tokenIdERC721 asset identifier.
networkClientIdNetwork 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:

NameDescription
nftAddressERC1155 token address.
senderAddressERC1155 token sender.
recipientAddressERC1155 token recipient.
nftIdERC1155 token id.
qtyQuantity of tokens to be sent.
networkClientIdNetwork 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>