Tokens not appearing in Metamask

Hi,

I have carried out a transaction, signed with meta mask and see this in the console:

I then see the successful transaction on the BSC network:

https://bscscan.com/tx/0xb3f438f7e4f9c7abea2fab89e07d9d7b820774738d99eabd16428b7d203be129

But, the AAT tokens are not appearing in my metamask wallet.

Looking at the transaction, i dont see any reference to the token address that i purchased. Could anyone explain what goes on with a transaction and importantly, where my BNB and purchased tokens have gone?

I am testing this process so i can build out a DEX so would like to know what im doing wrong. In Moralis i have a BSC Mainnet server and the 1inch plugin installed.

Thanks in advance

1 Like

it looks like you received pancake swap token:

x = await Moralis.Web3API.account.getTokenBalances({"chain":"bsc","address":"0x4ad4d42275f1cb5ca4b9e495aa2ba28a76d34780" })

=>

{
    "token_address": "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
    "name": "PancakeSwap Token",
    "symbol": "Cake",
    "logo": null,
    "thumbnail": null,
    "decimals": "18",
    "balance": "46807906871627727"
}

Still have this issue where the swap say its successful, the BNB goes down but the tokens don’t appear in my metamask wallet. Here is some detail of the swap - this is on the BSC Mainnet.

Transaction ID: https://bscscan.com/tx/0xc4cf19c2b284f0fa11c7342ff16acd3848519bcaaacb47de22986e037a816c9c

{
  fromToken: {
    symbol: 'BNB',
    name: 'BNB',
    decimals: 18,
    address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
    logoURI: 'https://tokens.1inch.io/0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c.png'
  },
  toToken: {
    symbol: 'DOT',
    name: 'DOT',
    decimals: 18,
    address: '0x7083609fce4d1d8dc0c979aab8c869ea2c873402',
    logoURI: 'https://tokens.1inch.io/0x7083609fce4d1d8dc0c979aab8c869ea2c873402.png'
  },
  toTokenAmount: '201008',
  fromTokenAmount: '10000',
  protocols: [ [ [Array] ] ],
  estimatedGas: 252364
}
quotedata 252364
quotedata [[[{"name":"JULSWAP","part":100,"fromTokenAddress":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","toTokenAddress":"0x7083609fce4d1d8dc0c979aab8c869ea2c873402"}]]]

Any help would be appreciated.

I don’t completely understand that transaction that you pasted there, I have the impression that DOT was changed to WBNB in that transaction

if you use something like:

x = await Moralis.Web3API.account.getTokenBalances({"chain":"bsc","address":ADDRESS })

then you get the expected output?

This is the code im using to do the swap. Im very close to this working - but need to see those tokens back in my wallet and i’m not sure why they are going missing.

const Web3 = require("web3");
const axios = require("axios");
require("dotenv").config();

const RPC_URL = process.env.RPC_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
let quoteData;

const web3 = new Web3(RPC_URL);
const wallet = web3.eth.accounts.wallet.add(PRIVATE_KEY);

async function quote() {
  try {
    const response = await axios.get(
      "https://api.1inch.exchange/v4.0/56/quote?fromTokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&toTokenAddress=0x7083609fce4d1d8dc0c979aab8c869ea2c873402&amount=10000"
    );
    console.log(response.data);
    quoteData = response.data;
  } catch (err) {
    console.log("Quote encountered an error below");
    console.log(err);
  }
}

async function swapper() {
  const gasPrice = await web3.eth.getGasPrice();
  try {
    const response = await axios.get(
      `https://api.1inch.exchange/v4.0/56/swap?fromTokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&toTokenAddress=0x7083609fce4d1d8dc0c979aab8c869ea2c873402&amount=10000&fromAddress=0x4Ad4D42275f1Cb5ca4B9E495aA2ba28a76D34780&slippage=15&destReceiver=0x4Ad4D42275f1Cb5ca4B9E495aA2ba28a76D34780`
    );
    console.log(response);
    if (response.data) {
      data = await response.data;
      data.tx.gas = quoteData.estimatedGas;
 
      console.log(data.tx);
      tx = await web3.eth.sendTransaction(data.tx);
      if (tx.status) {
        console.log("Swap Successfull! :)");
      }
    }
  } catch (err) {
    console.log("swapper encountered an error below");
    console.log(err);
  }
}

async function main() {
  await quote();
  await swapper();
}

main();

Interesting that i see transfers when i search holders with my wallet address but not updating in metamask

maybe metamask doesn’t properly update the token value, you can check directly the balance on the token smart contract