Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVM custom tokens import #385

Open
shamardy opened this issue Nov 18, 2024 · 0 comments
Open

EVM custom tokens import #385

shamardy opened this issue Nov 18, 2024 · 0 comments

Comments

@shamardy
Copy link

KDF PR: KomodoPlatform/komodo-defi-framework#2141

Adds support for enabling custom EVM (ERC20, PLG20, etc..) tokens without requiring them to be in the coins config. This allows users to interact with any ERC20 token by providing the contract address.

New RPC: get_token_info

Retrieves token information (symbol/ticker, decimals) from the contract. This RPC should be used before enabling a token to:

  • Get token details for GUI display
  • Check if token exists in config
  • Determine activation method (custom or config)

Request

{
  "userpass": "**********",
  "mmrpc": "2.0",
  "method": "get_token_info",
  "params": {
    // Protocol information required for custom tokens, same format as protocol info used in config
    "protocol": {
      "type": "ERC20",
      "protocol_data": {
        "platform": "ETH",
        "contract_address": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"
      }
    }
  }
}

Response (Success)

{
  "mmrpc": "2.0",
  "result": {
    "type": "ERC20",
    "info": {
      "symbol": "QTC", // The ticker to populate for the GUI user.
      "decimals": 8 // The decimals to populate for GUI user.
    }
  }
}

Response (Success) - Case for if the same contract address is used for a coin in configuration

{
  "mmrpc": "2.0",
  "result": {
    "config_ticker": "ERC20DEV", // This will show the ticker used in config, we should populate this to the user and use it to enable the token from config in the activation request. If we can show the user the contract ticker it would be good as well.
    "type": "ERC20",
    "info": {
      "symbol": "QTC",
      "decimals": 8
    }
  }
}

Updated RPC: task::enable_erc20::init/enable_erc20

Both should work for custom tokens, but we should be moving to task manager ones for trezor support.

Request (Enable a custom token)

{
  "userpass": "**********",
  "mmrpc": "2.0",
  "method": "task::enable_erc20::init",
  "params": {
    "ticker": "QTC", // 
    // New Field: protocol field required for custom tokens, same format as protocol info used in config
    "protocol": {
      "type": "ERC20",
      "protocol_data": {
        "platform": "ETH",
        "contract_address": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"
      }
    }
    // Other fields are the same
}

Success Response should be the same as response for non custom tokens but should be shown as wallet only in GUIs

Response (Error) - Token with this contract is already activated

{
  "error_type": "CustomTokenError",
  "error_data": {
    "TokenWithSameContractAlreadyActivated": {
      "ticker": "QTC",
      "contract_address": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"
    }
  }
}

This error indicates the contract is already activated with ticker "QTC".

Response (Error) - Token with this contract is in coin config

{
  "error_type": "CustomTokenError",
  "error_data": {
    "DuplicateContractInConfig": {
      "ticker_in_config": "ERC20DEV"
    }
  }
}

This error indicates the token should be enabled using the config ticker "ERC20DEV".

Important notes:

  • Always use get_token_info before enabling a custom token to:
    • Get token details for GUI display
    • Check if token exists in config
  • Custom tokens are wallet-only
  • Cannot activate same contract address twice
  • If token exists in config, use config details for GUI display and activation
  • Platform coin must be enabled before enabling any custom tokens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants