Provide Token | Developers

Provide Token

Estimated reading time: One minute

If the Ethereum App finds information on the requested tokens, it will be in msg->item1 and msg->item2.

In our plugin, we need to account for when the Ethereum App does NOT find the token.

Here is the code for our plugin, with comments:

    if (msg->item1) {
        // The Ethereum App found the information for the requested token!
        // Store its decimals.
        context->decimals = msg->item1->decimals;
        // Store its ticker.
                (char *) msg->item1->ticker,

        // Keep track of the token found.
        context->token_found = true;
    } else {
        // The Ethereum App did not manage to find 
        // the info for the requested token.
        context->token_found = false;

        // Default to ETH decimals (for wei).
        context->decimals = 18;
        // Default to "???" when information was not found.
        strlcpy(context->ticker, "???", sizeof(context->ticker));
        // If we wanted to add a screen, say a warning screen for example,
        // then we tell the Ethereum app to add an additional screen
        // by setting `msg->additionalScreens` here, just like so:
        // msg->additionalScreens = 1;

The code is straightforward. Note that msg->additionalScreens tells the Ethereum App it needs X additional screens.

The next step is about how to word your first screen.

Did you find this page helpful?

How would you improve this page for developers?

Query Contract ID
Getting Started
Theme Features