Skip to content

Commit

Permalink
changed static codeblocks for imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-tortora committed Sep 14, 2023
1 parent da0f91e commit 21fe18d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 160 deletions.
42 changes: 4 additions & 38 deletions docs/build/iota-sdk/1.0.0/docs/getting-started/nodejs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,50 +121,16 @@ Prebuild requires that the binary is in `build/Release` as though it was built w

After you [installed the library](#install-the-iota-sdk), you can create a `Client` instance and interface with it.

```javascript
const { Client, initLogger } = require('@iota/sdk');

async function run() {
initLogger();

const client = new Client({
nodes: ['https://api.testnet.shimmer.network'],
localPow: true,
});

try {
const nodeInfo = await client.getInfo();
console.log('Node info: ', nodeInfo);
} catch (error) {
console.error('Error: ', error);
}
}

run().then(() => process.exit());
```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/client/getting-started.ts#L4-L23
```

### Wallet

After you [installed the library](#installing-the-iota-sdk), you can create a `Wallet` instance and interact with it.

```javascript
import { Wallet, CoinType, WalletOptions } from '@iota/sdk';

const walletOptions: WalletOptions = {
storagePath: `Alice`, // A name to associate with the created account.
clientOptions: {
nodes: ['https://api.testnet.shimmer.network'], // The node to connect to.
},
coinType: CoinType.Shimmer,
secretManager: {
// Setup Stronghold secret manager
stronghold: {
snapshotPath: 'vault.stronghold', // The path to store the account snapshot.
password: 'a-secure-password', // A password to encrypt the stored data. WARNING: Never hardcode passwords in production code.
},
},
};
const wallet = new Wallet(walletOptions);
```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/wallet/getting-started.ts#L4-L60
```

## What's next?
Expand Down
32 changes: 4 additions & 28 deletions docs/build/iota-sdk/1.0.0/docs/getting-started/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,40 +92,16 @@ deactivate

After you [installed the library](#install-the-iota-sdk), you can create a `Client` instance and interface with it.

```python
from iota_sdk import Client

# Create a Client instance
client = Client(nodes=['https://api.testnet.shimmer.network'])

# Get the node info
node_info = client.get_info()
print(f'{node_info}')
```python reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/python/examples/client/getting_started.py
```

### Wallet

After you [installed the library](#install-the-iota-sdk), you can create a `Wallet` instance and interact with it.

```python
from iota_sdk import Wallet, StrongholdSecretManager, CoinType

# This example creates a new database and account

wallet_options = {
'nodes': ['https://api.testnet.shimmer.network'],
}

secret_manager = StrongholdSecretManager("wallet.stronghold", "some_hopefully_secure_password")

wallet = Wallet('./alice-database', wallet_options, coin_type=CoinType.SHIMMER, secret_manager)

# Store the mnemonic in the Stronghold snapshot. This only needs to be done once
account = wallet.store_mnemonic("flame fever pig forward exact dash body idea link scrub tennis minute " +
"surge unaware prosper over waste kitten ceiling human knife arch situate civil")

account = wallet.create_account('Alice')
print(account)
```python reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/python/examples/wallet/getting_started.py#L4-L48
```

## What's next?
Expand Down
60 changes: 4 additions & 56 deletions docs/build/iota-sdk/1.0.0/docs/getting-started/rust.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,69 +137,17 @@ iota-sdk = "1.0.0"

To use the Client module, you simply need to create a `Client`.

```rust
use iota_sdk::client::{Client, Result};

#[tokio::main]
async fn main() -> Result<()> {
let client = Client::builder()
.with_node("https://api.testnet.shimmer.network")? // Insert your node URL here
.finish()
.await?;

let info = client.get_info().await?;
println!("Node Info: {info:?}");

Ok(())
}
```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/client/getting_started.rs#L10-L23
```

### Wallet

To use the Wallet module, you need to create a `Wallet`.
For this example to work `features = ["stronghold"]` is needed in the Cargo.toml import. To persist the wallet in a database, `"rocksdb"` can be added.

```rust
use iota_sdk::{
client::{
constants::SHIMMER_COIN_TYPE,
secret::{stronghold::StrongholdSecretManager, SecretManager},
},
wallet::{ClientOptions, Result, Wallet},
};

#[tokio::main]
async fn main() -> Result<()> {
// Setup Stronghold secret manager.
// WARNING: Never hardcode passwords in production code.
let secret_manager = StrongholdSecretManager::builder()
.password("password".to_owned()) // A password to encrypt the stored data.
.build("vault.stronghold")?; // The path to store the account snapshot.

let client_options = ClientOptions::new().with_node("https://api.testnet.shimmer.network")?;

// Set up and store the wallet.
let wallet = Wallet::builder()
.with_secret_manager(SecretManager::Stronghold(secret_manager))
.with_client_options(client_options)
.with_coin_type(SHIMMER_COIN_TYPE)
.finish()
.await?;

// Generate a mnemonic and store it in the Stronghold vault.
// INFO: It is best practice to back up the mnemonic somewhere secure.
let mnemonic = wallet.generate_mnemonic()?;
wallet.store_mnemonic(mnemonic).await?;

// Create an account.
let account = wallet
.create_account()
.with_alias("Alice") // A name to associate with the created account.
.finish()
.await?;

Ok(())
}
```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/wallet/getting_started.rs#L12-L56
```

## What's next?
Expand Down
42 changes: 4 additions & 38 deletions docs/build/iota-sdk/1.0.0/docs/getting-started/wasm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,50 +147,16 @@ A bundler such as [webpack](https://webpack.js.org/) or [rollup](https://rollupj

After you [installed the library](#install-the-iota-sdk), you can create a `Client` instance and interface with it.

```javascript
const { Client, initLogger } = require('@iota/sdk');

async function run() {
initLogger();

const client = new Client({
nodes: ['https://api.testnet.shimmer.network'],
localPow: true,
});

try {
const nodeInfo = await client.getInfo();
console.log('Node info: ', nodeInfo);
} catch (error) {
console.error('Error: ', error);
}
}

run().then(() => process.exit());
```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/client/getting-started.ts#L4-L23
```

### Wallet

After you [installed the library](#installing-the-iota-sdk), you can create a `Wallet` instance and interact with it.

```javascript
import { Wallet, CoinType, WalletOptions } from '@iota/sdk';

const walletOptions: WalletOptions = {
storagePath: `Alice`, // A name to associate with the created account.
clientOptions: {
nodes: ['https://api.testnet.shimmer.network'], // The node to connect to.
},
coinType: CoinType.Shimmer,
secretManager: {
// Setup Stronghold secret manager
stronghold: {
snapshotPath: 'vault.stronghold', // The path to store the account snapshot.
password: 'a-secure-password', // A password to encrypt the stored data. WARNING: Never hardcode passwords in production code.
},
},
};
const wallet = new Wallet(walletOptions);
```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/wallet/getting-started.ts#L4-L60
```

### Web Usage
Expand Down

0 comments on commit 21fe18d

Please sign in to comment.