I have a question about the wallet sent

I am currently learning about wallet sending and now I have a question.
One mnemonic corresponds to many addresses, and one address has many utxo
wallet: address1(baseaddr), address2(asset1)
What I restore by mnemonic is address1, but I want to send asset1

(The official documentation describes the mnemonic word generation address, but this address does not have ADA, then send ADA to this address from the faucet)

Multiple addresses can be derived from the same mnemonic. Are you using a script you found online for deriving the address? Those scripts might only give the first address and might need some tweaking for deriving more addresses. Can you point to the script you used?

yes,I am java coder.

Don’t ask the same question in multiple forum posts…

The address is an encoding of a hash of a public key. Different address means different public key, means different private key. A transaction such as Transaction 9f56ebbf115dc4a5d0370117b164800a74033b9e84b4fd0cefdd65cdbf5e7582 - Cardanoscan, which takes inputs from different addresses has to be signed by multiple private keys for all of the input addresses.

Wallet apps do that automatically. They can derive the private keys by the process described, e.g., in Address Derivation – Cardano Wallet.
It doesn’t matter if the addresses are staked or not (“enterprise”) for this.

If that can be done with this (quite strange) Java API, I don’t know. It seems their transaction builder assumes that there is only one “sender” for each transaction.

In that issue, you mention that the proposed solution with selecting another index in the Account constructor did not work.

Did you choose the index for the address, where the asset resides? It’s the last component of the m/1852’/… derivation path shown to you by Eternl.

According to this, I solve it.

DerivationPath build = DerivationPath.builder()
.purpose(new Segment(1852, true))
.coinType(new Segment(1815, true))
.account(new Segment(0, true))
.role(new Segment(1, false))
.index(new Segment(2, false))
.build();
Not only need to modify (index), but also need to modify (role)
address: m/1852’/1815’/0’/1/2

That role part you’re speaking about is typically used for separating receive addresses (0) and change addresses (1). Technically their isn’t a difference between those two and you can use either as receive, change or both, but the BIP44 standard makes this distinction. Cardano adds another role, namely 2 for stake key.

See CIPs/README.md at master · cardano-foundation/CIPs · GitHub

The reason you had to change the role to 1 is because the address you needed probably was a change address in the wallet.

1 Like