0

I am creating an ERC20 token transfer transaction and proposing it to the safe service. Now when we fetch pending/multisign transactions using getMultisigTransactions or getPendingTransactions, the token transfer related transactions does not contain token info like token decimal or token symbol. So, how do we show the token amount(token value/decimals) or token symbol on UI properly? Currently, as we have token contract address in the to field of the transaction, so using this I am creating a contract instance and calling like this:

    const decimal = await tokenInstance.methods.decimals().call()
    const symbol = await tokenInstance.methods.symbol().call()

to get the token info. I feel like doing this is not an ideal way because we have to do this for all the token transfer related transactions which could slow the rendering of the transaction list on the UI.

7
  • Hi @Richard, this question is related to safe service as well, when we fetch pending/multisign transactions then that transaction does not contain the token info. I am a bit confused now, is this a general issue or how does Safe UI do this? Commented Jan 5, 2022 at 13:39
  • 1
    The Safe UI has a service that holds/ indexes these information and prepares them for the client. Your question is not specific to the Safe contracts or Safe UI, therefore the gnosis-safe tag was removed.
    – Richard
    Commented Jan 5, 2022 at 14:06
  • ok got it. Then let me edit the question and make it specific to gnosis safe because I wanted to ask that getMultisigTransactions or getPendingTransactions functions of safe service does not contain token info in the token transfer transactions. Sorry for inconvenience. Commented Jan 5, 2022 at 14:18
  • Using to field has some issues as well. I accidentally created and executed an erc20 token transfer transaction with to field containing an EOA address. Now I cannot differentiate this transaction with other ecr20 token transfer transactions because I am filtering such transactions on the basis of response[i].dataDecoded.method === 'transfer' condition. Now, this accidental transaction is bypassing this check and when I try to create a contract instance using to field value I simply get an error because the address is not a contract address. :( Commented Jan 5, 2022 at 15:58
  • 1
    You should handle errors in any case. The answer from @gazoblock outlines some optimizations. The Safe team does not focus on providing a service to retrieve token information, there are other services available for this. There are quite some other services for this. But in general it should not post a problem to query the token information from the contract directly if you apply proper caching and error handling.
    – Richard
    Commented Jan 5, 2022 at 16:02

1 Answer 1

1

If you want to know token info about some token, this is best way to get it (without using 3rd part APIs or your own database with this information). But if you care about perfomance on UI, you could use multicall, to retrieve all desired tokens info in 1 call and parse result offchain.

1
  • Additionally you should cache the information locally (e.g. in local storage).
    – Richard
    Commented Jan 5, 2022 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.