I want to get a list with the MultiversX's ESDT tokens (and balances) from an address (a wallet). I don't have any example, I tried things such as:
const { address, account } = useGetAccountInfo();
const objAddress = new Address(address);
// const data1 = getAccount(address);
const { network } = useGetNetworkConfig();
const proxy = new ProxyProvider(network.apiAddress);
proxy
.getAddressEsdtList(objAddress)
.then(({ returnData }) => {
console.log(returnData);
})
.catch((err) => {
console.error('Unable to call VM query', err);
});
But in the console I get "undefined".
In the latest
erdjs
version I don't have anygetAddressEsdtList
function for the provider; what could work is to extend the network providers.So we know we can extend the available network providers with other functions and we now need to make a request with an address and receive all the tokens that the address helds.
api.elrond.com
has an endpoint that does this ataccounts/{address}/tokens
.As we have an endpoint to make a request to, we can now extend the
ApiNetworkProvider
, making use ofdoGetGeneric
.