Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
Solana method cannot convert string to Base58 format

I'm using @solana/web3.js and have this code:

const web3 = require("@solana/web3.js");
const clusterApi = process.env.SOLANA_CLUSTER;
module.exports = {
    getConfirmedSignaturesForAddress: async address => {
    try {
      const connection = new web3.Connection(web3.clusterApiUrl(clusterApi), "confirmed");

      const result = await connection.getSignaturesForAddress(address, {
        limit: 25
      });

      return {
        tx: result,
        status: true
      };
    } catch (e) {
      return {
        status: false,
        error: e.message
      };
    }
  }
}

And every time I call this function I get this error:

{ status: false, error: 'address.toBase58 is not a function' }

I was trying to send it already converted to Base58, but it just doesn't work. What's wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is how I solved this problem. Generally speaking, you need to convert it not just by converting to pure Base58, but like this:

const web3 = require("@solana/web3.js");
const bip39 = require("bip39");

const getKeyFromMemonic = async mnemonic => {
  return new Promise((resolve, reject) => {
    bip39
      .mnemonicToSeed(mnemonic)
      .then(buffer => {
        const a = new Uint8Array(buffer.toJSON().data.slice(0, 32));
        const key = web3.Keypair.fromSeed(a);
        resolve(key);
      })
      .catch(err => reject(err));
  });
};

getSignaturesForAddress: async address => {
    try {
      const key = await getKeyFromMemonic(address);

      const connection = new web3.Connection(web3.clusterApiUrl(clusterApi), "confirmed");

      const result = await connection.getSignaturesForAddress(key.publicKey);

      return {
        tx: result,
        status: true
      };
    } catch (e) {
      return {
        status: false,
        error: e.message
      };
    }
  }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda