cardano-foundation / ledger-app-cardano

Cardano Ledger App for Ledger Nano S
Apache License 2.0
25 stars 14 forks source link

Regarding the issue with Ledger address generation #21

Open fancydd opened 5 days ago

fancydd commented 5 days ago

Hey, I’m running into an issue – I noticed that the address generated by Ledger is different from Trust and other software wallets. Do you have any thoughts or suggestions on why that might be?

Tao546127REP commented 5 days ago

Hey, I’m running into an issue – I noticed that the address generated by Ledger is different from Trust and other software wallets. Do you have any thoughts or suggestions on why that might be?

Hey @fancydd It's common to see different addresses generated by Ledger and other software wallets because they can use different address derivation paths or formats. Ledger typically follows the BIP32/BIP44 standards, but different wallets may implement these standards slightly differently or use different derivation paths.

Make sure you're using the same derivation path in both wallets. For example, if you're looking for Bitcoin addresses, the standard path is usually m/44'/0'/0'/0 for legacy addresses or m/49'/0'/0'/0 for SegWit. If the wallets are set to different paths, they will generate different addresses.

If you're still having issues, double-check the settings in both wallets and ensure they are compatible with each other. Let me know if you need more help with this.

fancydd commented 5 days ago

I am looking for address generation in Cardano. Can you help me with an example of generating an address through a mnemonic using Ledger?

Tao546127REP commented 5 days ago

I am looking for address generation in Cardano. Can you help me with an example of generating an address through a mnemonic using Ledger?

hey @fancydd Sure! To generate a Cardano address using a mnemonic with a Ledger device, you can follow these steps:

  1. Set Up Your Ledger: Make sure your Ledger device is connected and the Cardano app is installed.

  2. Use a Wallet Interface: You can use a wallet interface that supports Ledger and Cardano, such as Daedalus or Yoroi.

  3. Import Your Mnemonic:

    • Open the wallet application (e.g., Yoroi).
    • Choose the option to restore a wallet.
    • Select the option to use a mnemonic phrase.
    • Enter your 12 or 24-word mnemonic phrase when prompted.
  4. Choose the Derivation Path: Cardano typically uses the derivation path m/44'/1815'/0'/0 for generating addresses. Ensure that your wallet is set to this path.

  5. Generate the Address: Once the mnemonic is entered and the wallet is restored, the application will generate your Cardano addresses. You should see your wallet balance and transaction history if everything is set up correctly.

  6. Verify the Address: You can generate multiple addresses from the same mnemonic. Make sure to verify that the addresses generated match the ones you had previously.

If you have any specific questions about the process or need more detailed steps for a particular wallet, feel free to ask!

fancydd commented 4 days ago

Sorry, I may not have explained it clearly enough. I need an example of converting a mnemonic to an address without using Ledger. It can be in JavaScript or Java

fancydd commented 4 days ago

@Tao546127REP hi

Tao546127REP commented 4 days ago

Sorry, I may not have explained it clearly enough. I need an example of converting a mnemonic to an address without using Ledger. It can be in JavaScript or Java

Hey @fancydd Sure! Here’s an example of how to convert a mnemonic phrase to an Ethereum address using JavaScript and the ethers.js library.

JavaScript Example

First, make sure you have the ethers library installed. You can install it via npm:

npm install ethers

Then, you can use the following code:

const { ethers } = require('ethers');

async function mnemonicToAddress(mnemonic) { // Create a wallet from the mnemonic const wallet = ethers.Wallet.fromMnemonic(mnemonic);

// Get the address
const address = wallet.address;

return address;

}

// Example mnemonic const mnemonic = "test test test test test test test test test test test test"; // Replace with your mnemonic

mnemonicToAddress(mnemonic).then(address => { console.log("Ethereum Address:", address); }).catch(error => { console.error("Error:", error); });

Java Example

If you prefer Java, you can use the web3j library. Make sure to add the dependency in your pom.xml if you’re using Maven:

org.web3j core 4.8.7

Here’s how you can convert a mnemonic to an Ethereum address in Java:

import org.web3j.crypto.WalletUtils; import org.web3j.crypto.Bip39Wallet; import org.web3j.crypto.MnemonicUtils; import org.web3j.crypto.WalletFile; import org.web3j.crypto.Credentials; import org.web3j.utils.Numeric;

public class MnemonicToAddress {

public static void main(String[] args) {
    String mnemonic = "test test test test test test test test test test test test"; // Replace with your mnemonic

    // Generate the seed from the mnemonic
    byte[] seed = MnemonicUtils.generateSeed(mnemonic, null);

    // Generate the wallet
    Bip39Wallet bip39Wallet = WalletUtils.generateBip39Wallet("", seed);
    Credentials credentials = Credentials.create(bip39Wallet.getPrivateKey());

    // Get the address
    String address = credentials.getAddress();

    System.out.println("Ethereum Address: " + address);
}

}

Notes

•   Replace the example mnemonic with your own 12-word or 24-word phrase.
•   Make sure to handle any exceptions or errors as necessary, especially for invalid mnemonics.
fancydd commented 2 days ago

hi @Tao546127REP . I need a generating code for cardano, not eth

fancydd commented 1 day ago

hi @Tao546127REP are you still there

Tao546127REP commented 1 day ago

hi @Tao546127REP . I need a generating code for cardano, not eth

Hey @fancydd sorry for the late response you can drop your telegram in the next comment

To generate a Cardano wallet, you can use the cardano-wallet library. Below is a simple example of how to create a new Cardano wallet using JavaScript:

const { WalletServer } = require('cardano-wallet');

async function createCardanoWallet() {
  const walletServer = WalletServer.init('http://localhost:8090/v2'); // Adjust the URL based on your wallet server configuration

  const walletName = 'MyCardanoWallet';
  const mnemonic = 'your mnemonic phrase here'; // Replace with your actual mnemonic phrase
  const passphrase = 'your wallet passphrase'; // Replace with your desired passphrase

  try {
    const wallet = await walletServer.wallets.create({
      name: walletName,
      style: 'random', // or 'random', 'fromMnemonic'
      mnemonic_sentence: mnemonic,
      passphrase: passphrase,
    });

    console.log('Wallet created successfully:', wallet);
  } catch (error) {
    console.error('Error creating wallet:', error.message);
  }
}

// Call the function to create the wallet
createCardanoWallet();

Make sure you have the cardano-wallet library installed and that your Cardano wallet server is running. Replace the placeholders with your actual mnemonic and passphrase. If you need further assistance or have questions about specific parts of the code, feel free to ask!

fancydd commented 1 day ago

thank you very much!my telegram is Abe586 @Tao546127REP

fancydd commented 1 day ago

did you see that? Please add me, I have some more questions @Tao546127REP

Tao546127REP commented 1 day ago

did you see that? Please add me, I have some more questions @Tao546127REP

Already added you on telegram @fancydd