Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda