Misconfigured coin type affecting Cerberus airdrop for Chihuahua users

danikar_pn

Danikar

Posted on March 16, 2022

Misconfigured coin type affecting Cerberus airdrop for Chihuahua users

Update: Here is a video guide on what I did here below https://www.youtube.com/watch?v=EteFbbKUz94

The recent Cerberus airdrop to Chihuahua delegators went smoothly for the most part. However, some users found they were not able to see their $CRBRUS in their new wallet.

The cause I noticed for this issue is a misconfigured Chihuahua chain in Keplr. For most Cosmos chains, the coin type is set to 118, however, some users have Chihuahua chain misconfigured with coinType of 139 or 639. It's possible that it could be set to something completely different. The $CRBUS is sent to the Cerberus wallet that corresponds to the Chihuahua wallet. Meaning, if the Chihuahua wallet uses coin type 139, we need to use coinType 139 on Cerberus. However, Cerberus is configured with coin type 118 as it should be.

Here I present a way to configure Cerberus to use the coin type required.

To recover $CRBRUS from a misconfigured Chihuahua wallet, we first need to find out which coinType was used. I wrote the following script that derives the address for each coin type, and compares it to our target address. Be careful with this since you need to paste your mnemonic here. For ledger wallets something more clever will need to be done since you should not put your mnemonic in a script with a hardware wallet.

const { DirectSecp256k1HdWallet } = require("@cosmjs/proto-signing");
const { stringToPath } = require("@cosmjs/crypto");

const MNEMONIC = "surround miss nominee dream gap cross " + 
                 "assault thank captain prosper drop duty " +
                 "group candy wealth weather scale put";
const COIN_TYPE_MIN = 0;
const COIN_TYPE_MAX = 1000;
const TARGET_ADDRESS = "chihuahua132fuyjqzew4kw87atymc66d03dta243artgrgf";
const ADDRESS_PREFIX = "chihuahua";

async function main() {
  for (
    let coinType = COIN_TYPE_MIN;
    coinType <= COIN_TYPE_MAX;
    coinType++
  ) {
    const wallet = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC, {
      hdPaths: [stringToPath(`m/44'/${coinType}'/0'/0/0`)],
      prefix: ADDRESS_PREFIX,
    });
    const [account] = await wallet.getAccounts();
    if (account.address === TARGET_ADDRESS) {
      console.log(`Address found on coinType ${coinType}`);
      return;
    }
  }
  console.log("Address not found for any coin type in range.")
}

main();
Enter fullscreen mode Exit fullscreen mode

Now that we have our coinType, we need to configure Keplr for Cerberus with this coinType. The tricky part here is using an experimental API to suggest a chain configuration to Keplr, and the method is a bit buggy. If you already added Cerberus to Keplr, deleting the chain from Keplr does not seem to be enough. When you re add it, it keeps the old coinType. I found removing all accounts from Keplr, and restoring my account with the mnemonic fixed this issue.

To add Cerberus to Keplr with a new chainId. Delete all accounts from Keplr, or uninstall and reinstall. Ensure you have mnemonics to restore your accounts.

Then run the following command in a browser Javascript console. Adjust the coin type as needed.

const COIN_TYPE = 639;
window.keplr.experimentalSuggestChain({
  chainId: "cerberus-chain-1",
  chainName: "Cerberus",
  rpc: "https://rpc.cerberus.zone:26657",
  rest: "https://api.cerberus.zone:1317",
  walletUrlForStaking: "https://stake.cerberus.zone/",
  stakeCurrency: {
    coinDenom: "CRBRUS",
    coinMinimalDenom: "ucrbrus",
    coinDecimals: 6,
  },
  bip44: {
    coinType: COIN_TYPE,
  },
  bech32Config: {
    bech32PrefixAccAddr: "cerberus",
    bech32PrefixAccPub: "cerberuspub",
    bech32PrefixValAddr: "cerberusvaloper",
    bech32PrefixValPub: "cerberusvaloperpub",
    bech32PrefixConsAddr: "cerberusvalcons",
    bech32PrefixConsPub: "cerberusvalconspub",
  },
  currencies: [
    {
      coinDenom: "CRBRUS",
      coinMinimalDenom: "ucrbrus",
      coinDecimals: 6,
    },
  ],
  feeCurrencies: [
    {
      coinDenom: "CRBRUS",
      coinMinimalDenom: "ucrbrus",
      coinDecimals: 6,
    },
  ],
  gasPriceStep: {
    low: 0.01,
    average: 0.025,
    high: 0.04,
  },
})
Enter fullscreen mode Exit fullscreen mode

At this point you should be able to access your $CRBRUS. I would recommend sending your crypto to the Cerberus address with coin type 118 so you don't need to deal with this in the future. I would also move your $HUAHUA to an address with coin type 118.

After you are done with this process, you should reset Keplr again by deleting accounts or uninstalling and reinstalling, and add Chihuahua and Cerberus normally through a trusted application. For example, https://chihuahua.omniflix.co/stake and https://stake.cerberus.zone/.

I am not entirely confident that all users will be able to execute the steps above, and it would be better if we could configure chain info directly through Keplr or another wallet application. It is very unintuitive on how to discover the current coin type, and extremely inconvenient to change it in Keplr as it exists today.

If you found this content helpful, and you are a part of the Chihuahua or Cerberus community, I am looking for delegations to both my Chihuahua and Cerberus validators https://linktr.ee/danikar_pn

💖 💪 🙅 🚩
danikar_pn
Danikar

Posted on March 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related