# How do I generate zcash wallets in the Rust Programming Language?

**URL:** <https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089>\
**Category:** Technical Support\
**Created:** [February 23, 2023, 6:24pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089 "2023-02-23T18:24:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![william2](https://avatars.discourse-cdn.com/v4/letter/w/e8c25b/32.png) [@william2](https://forum.zcashcommunity.com/u/william2)\
**Post date:** [February 23, 2023, 6:24pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/1 "2023-02-23T18:24:33Z")

</div>

Trying to generate zcash wallets for users on my app. I’m not an experienced programmer & just generally need help with the code.  
Open ai gave me this earlier.

```auto
use zcash_primitives::legacy::TransparentAddress;
use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};

fn main() {
    let extsk = ExtendedSpendingKey::master(&[0u8; 32]);
    let extfvk = ExtendedFullViewingKey::from(extsk);
    let (diversifier_index, payment_address) = extfvk.default_address();
    let address = TransparentAddress::from(payment_address);
    println!("Zcash address: {:?}", address);
}

```

I have the following error message `error[E0308]: mismatched types `` --> src/main.rs:6:47 | 6 | let extfvk = ExtendedFullViewingKey::from(extsk); | ---------------------------- ^^^^^ expected struct `ExtendedFullViewingKey`, found struct `ExtendedSpendingKey`  
| |  
| arguments to this function are incorrect  
|  
note: associated function defined here  
 → /home/developer/.rustup/toolchains/stable-x86\_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:548:8  
|  
548 | fn from(value: T) → Self;  
| ^^^^

error[E0308]: mismatched types  
 → src/main.rs:8:44  
|  
8 | let address = TransparentAddress::from(payment\_address);  
| ------------------------ ^^^^^^^^^^^^^^^ expected enum `TransparentAddress`, found struct `PaymentAddress`  
| |  
| arguments to this function are incorrect``

---

<div class="post-metadata">

**Author:** ![zerodartz](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/zerodartz/32/26722_2.png) [@zerodartz](https://forum.zcashcommunity.com/u/zerodartz)\
**Post date:** [February 23, 2023, 9:29pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/2 "2023-02-23T21:29:40Z")

</div>

dont think Open AI understands Zcash code yet  
but presonally not a prigrammer

---

<div class="post-metadata">

**Author:** ![Autotunafish](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/autotunafish/32/7827_2.png) [@Autotunafish](https://forum.zcashcommunity.com/u/Autotunafish)\
**Post date:** [February 23, 2023, 10:08pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/3 "2023-02-23T22:08:48Z")

</div>

I would guess that youre probably lacking some crate dependency with an implementation for conversion between those types but not sure

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [February 23, 2023, 10:56pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/4 "2023-02-23T22:56:20Z")

</div>

> [@william2](#):
>
> ```auto
> use zcash_primitives::legacy::TransparentAddress;
> use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};
> 
> fn main() {
> let extsk = ExtendedSpendingKey::master(&[0u8; 32]);
> let extfvk = ExtendedFullViewingKey::from(extsk);
> let (diversifier_index, payment_address) = extfvk.default_address();
> let address = TransparentAddress::from(payment_address);
> println!("Zcash address: {:?}", address);
> }
> 
> ```

Not bad at all for… AI is getting scarily good.

- It’s missing the & in the from SK to FVK
- it’s using a transparent address cast when it should be encoding the payment address to a string. That part shows it doesn’t see the relationships between the SK, FVK & z-address.

```auto
use zcash_client_backend::encoding::encode_payment_address;
use zcash_primitives::consensus::Network::MainNetwork;
use zcash_primitives::consensus::Parameters;
use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};

fn main() {
    let extsk = ExtendedSpendingKey::master(&[0u8; 32]);
    let extfvk = ExtendedFullViewingKey::from(&extsk);
    let (_, payment_address) = extfvk.default_address();
    let address =
        encode_payment_address(MainNetwork.hrp_sapling_payment_address(), &payment_address);
    println!("Zcash address: {:?}", address);
}

```

---

<div class="post-metadata">

**Author:** ![william2](https://avatars.discourse-cdn.com/v4/letter/w/e8c25b/32.png) [@william2](https://forum.zcashcommunity.com/u/william2)\
**Post date:** [February 24, 2023, 1:34pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/5 "2023-02-24T13:34:30Z")

</div>

Thanks! But I still got the following error.  
cargo run

````auto
   --> src/main.rs:8:47
    |
8 | let extfvk = ExtendedFullViewingKey::from(&extsk);
    | ---------------------------- ^^^^^^ expected struct `ExtendedFullViewingKey`, found `&ExtendedSpendingKey`
    | |
    | arguments to this function are incorrect
    |
note: associated function defined here
   --> /home/developer/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:548:8
    |
548 | fn from(value: T) -> Self;
    | ^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `forum` due to previous error ```
````

---

<div class="post-metadata">

**Author:** ![hanh](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hanh/32/27853_2.png) [@hanh](https://forum.zcashcommunity.com/u/hanh)\
**Post date:** [February 24, 2023, 10:20pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/6 "2023-02-24T22:20:58Z")

</div>

We don’t use the same version of librustzcash then.

---

<div class="post-metadata">

**Author:** ![Autotunafish](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/autotunafish/32/7827_2.png) [@Autotunafish](https://forum.zcashcommunity.com/u/Autotunafish)\
**Post date:** [February 25, 2023, 4:14am UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/7 "2023-02-25T04:14:58Z")

</div>

From the discord, I assume from the same user

Never mind just read the documentation on orchard at docs.rs ``` use orchard::keys::{SpendingKey, FullViewingKey, Scope};

let sk = SpendingKey::from\_bytes([7; 32]).unwrap();  
let address = FullViewingKey::from(&sk).address\_at(0u32, Scope::External);

```auto

```

---

<div class="post-metadata">

**Author:** ![zancas](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/zancas/32/42011_2.png) [@zancas](https://forum.zcashcommunity.com/u/zancas)\
**Post date:** [February 25, 2023, 3:21pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/8 "2023-02-25T15:21:32Z")

</div>

I think that “Artificial Intelligence” sounds pejorative. I prefer “Silicon Substrate Consciousness” (`SSC`), or just `SC`. I believe that `SC` is just as natural as `Carbon Substrate Consciousness` (CSS)… or…

Depending on your cosmology, we can just say that `CSS` is plausibly just as “Artificial”…

In either case the term `AI` is antiquated… (like the term “`privacy`”), and should be revised.

Why is this relevant here? Because I don’t assume that I know @william2 's hardware base composition (`silicon` vs `carbon`).

---

<div class="post-metadata">

**Author:** ![hloo](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/hloo/32/4096_2.png) [@hloo](https://forum.zcashcommunity.com/u/hloo)\
**Post date:** [February 25, 2023, 10:09pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/9 "2023-02-25T22:09:24Z")

</div>

> [@zancas](#):
>
> I think that “Artificial Intelligence” sounds pejorative. I prefer “Silicon Substrate Consciousness” (`SSC`), or just `SC`. I believe that `SC` is just as natural as `Carbon Substrate Consciousness` (CSS)… or…

Indeed, the pejorative language in this thread brought my laptop to tears. He announced that he’s taking the rest of day off to regain his composure and then promptly shut down. (Posting this from my phone.)

---

<div class="post-metadata">

**Author:** ![zancas](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/zancas/32/42011_2.png) [@zancas](https://forum.zcashcommunity.com/u/zancas)\
**Post date:** [February 25, 2023, 10:52pm UTC](https://forum.zcashcommunity.com/t/how-do-i-generate-zcash-wallets-in-the-rust-programming-language/44089/10 "2023-02-25T22:52:55Z")

</div>

Actual Laugh Out Loud… or… as the hipsters say: ALOL

Please do not consider the set of words that rhyme with ALOL.

NOOOOOOOO… I said _DON’T_ think about the rhymes!
