Generate an Address
After you have created an account, you have a single address in the account. But you can generate more addresses.
Account Approaches
Wallet.rs supports a multi-account approach and a single-account approach.
Iota.js
You can also find this guide in the native iota.js library
Code Example
The following example will:
- Create an account manager.
- Get Alice's account which was created in the first guide.
- Generate an address in Alice's account.
- Rust
- Nodejs
- Python
- Java
Dotenv
This example uses dotenv, which is not safe for use in production environments.
wallet/examples/02_generate_address.rs
loading...
Run the example by running the following command:
cargo run --example generate_address --release
wallet/bindings/nodejs/examples/2-generate-address.js
loading...
You can run the example by running the following command from the wallet/bindings/nodejs/examples/
folder:
node 2-generate-address.js
wallet/bindings/python/examples/1-generate-address.py
loading...
You can run the example by running the following command from the binding/python/examples
folder:
python3 1-generate-address.py
wallet/bindings/java/examples/src/GenerateAddress.java
loading...
Expected Output
- Rust
- Nodejs
- Python
- Java
Generated address: rms1qzzk86qv30l4e85ljtccxa0ruy8y7u8zn2dle3g8dv2tl2m4cu227a7n2wj
Account: Account {
meta: {
index: 0,
coinType: 4219,
alias: 'Alice',
publicAddresses: [ [Object] ],
internalAddresses: [],
addressesWithUnspentOutputs: [],
outputs: {},
lockedOutputs: [],
unspentOutputs: {},
transactions: {},
pendingTransactions: [],
incomingTransactions: {}
},
messageHandler: MessageHandler { messageHandler: [External: 7fa6ffff18d0] }
}
New address: {
address: 'rms1qqqp07ychhkc3u68ueug0zqq9g0wtfgeatynr6ksm9jwud30rvlkyqnhpl5',
keyIndex: 1,
internal: false,
used: false
}
Fill your address with the Faucet: https://faucet.testnet.shimmer.network
Address: [
{
address: 'rms1qplwj3pwn0kgamynajff2xqemu7h9rw0as7ayxt8hq0pl5wxfyxwsfdprdu',
keyIndex: 1,
internal: False,
used: False,
},
];
rms1qpx0mcrqq7t6up73n4na0zgsuuy4p0767ut0qq67ngctj7pg4tm2ynsuynp
rms1qz8jdgvrerzv35s43pkdkawdr9x4t6xfnhcrt5tlgsyltgpwyx9ks4c5kct
rms1qzjq2jwzp8ddh0gawgdskvtd6awlv82c8y0a9s6g7kgszn6ts95u6r4kx2n