Skip to content

Commit

Permalink
Merge branch 'master' into docs/fix-cp-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-parkhill authored Oct 25, 2024
2 parents 937a58a + b45f52e commit d3ad5d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 66 deletions.
76 changes: 11 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ Dock Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or h
## Installation
```js
yarn add @docknetwork/wallet-sdk-core
yarn add @docknetwork/wallet-sdk-transactions
yarn add @docknetwork/wallet-sdk-react-native

```
**There are some scripts and additional dependencies required.**
Please check our [example repo](https://github.com/docknetwork/wallet-sdk-demo) for detailed steps.

## React Native Example
The following example will create a wallet and allow the user to add accounts on it. Displaying the count of documents added to the wallet.

Notice that the account documents are accessible through the `documents` object, and for each account created multiple documents will be added to the wallet.
The following example will create a wallet and allow the user to add credentials to it. Displaying the count of documents added to the wallet.
Notice that the all documents are accessible through the `documents` object.

```js
import {Box, Button, NativeBaseProvider, Text} from 'native-base';
Expand All @@ -39,8 +37,11 @@ const WalletDetails = function () {
<Box>
<Text>Wallet status: {status}</Text>
<Text>Wallet docs: {documents.length}</Text>
<Button onPress={() => wallet.accounts.create({name: 'test'})}>
<Text>Add Account</Text>
<Button onPress={() => wallet.addDocument({
name: 'my credential',
type: 'VerifiableCredential',
})}>
<Text>Add Credential</Text>
</Button>
</Box>
);
Expand All @@ -52,7 +53,7 @@ const App = () => {
<WalletSDKProvider>
<Box p={8}>
<Text>Dock Wallet SDK Demo</Text>
<Text>Press on `add document` button to create a new account</Text>
<Text>Press on `add credential` button to create a new credential</Text>
</Box>
<WalletDetails />
</WalletSDKProvider>
Expand All @@ -64,67 +65,12 @@ export default App;

```

## Using the wallet module

```js
import {Wallet} from '@docknetwork/wallet-sdk-core/lib/modules/wallet';
import {Transactions} from '@docknetwork/wallet-sdk-transactions/lib/transactions';

const wallet = await Wallet.create();

const account1 = await wallet.accounts.create({
name: 'test',
});

console.log(`Account1 address ${account1.address}`);
// result: Account1 address 3D1M9UnR684eBfVujjQr6ucPqvXERSxYxcVBFGAhRohhRXxq

// Create account using an existing mnemonic
const mnemonic =
'indicate mention thing discover clarify grief inherit vivid dish health market spoil';
const account2 = await wallet.accounts.create({
name: 'Test',
mnemonic,
});

console.log(`Account2 address ${account2.address}`);

// result: Account2 address 3FENesfZgFmBruv2H9Hc17GmobeTfxFAp8gHKXFmUtA38hcW

// Fetch accounts balance
const balance = await account1.getBalance();

console.log('Account1 balance', balance);
For more details you can check the [getting started guide](docs/getting-started.md).

// result: Account1 balance 0

// Handle transactions
const transactions = Transactions.with(account1);

const txInput = {
toAddress: account2.address,
amount: 3
};

// Get transaction fee in DOCK tokens
const fee = await transactions.getFee(txInput);

console.log('Transaction fee', fee);

// result: Transaction fee 2.3

// Send transaction
const hash = await transactions.send(txInput);

console.log('Transaction hash', fee);

// result: Transaction hash 0x1c1c5ca40acafb830460dccb492be4ac7181e9d700ab78853df052e478e8b2a9

```

## Running on nodejs
## Running on other platforms

Check the following repository for nodejs project examples.
Check the following repository for detailed examples for running the Dock Wallet SDK on NodeJS, Web, and Flutter.

https://github.com/docknetwork/wallet-sdk-examples

Expand Down
6 changes: 5 additions & 1 deletion packages/transactions/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

# Transactions Manager
# Deprecated Module

The transaction module is deprecated and will be removed in the future.

# Transactions Manager

Transactions are required to send and receive (DOCK Tokens)[[https://www.dock.io/token]. This module handles the transaction history and provides methods to send DOCK tokens to any address.

Expand Down

0 comments on commit d3ad5d8

Please sign in to comment.