Skip to content

Commit

Permalink
feat(global): add getting started section for root README
Browse files Browse the repository at this point in the history
  • Loading branch information
extg3 committed Jun 10, 2024
1 parent f8732d1 commit 62b0dd7
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 29 deletions.
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,88 @@ A JavaScript SDK for building workflows on the Ditto Network, enabling a Smart A
> [!WARNING]
> THESE ARE STILL IN DEVELOPMENT AND CAN BE CHANGED AT ANY TIME.

## Table of Contents

- [Introduction](#introduction)
- [Installation](#installation)
- [Getting Started](#getting-started)
- [Documentation](#documentation)
- [Project Structure](#project-structure)
- [Examples](#examples)
- [Contributing](#contributing)
- [Changelog](#changelog)


## Introduction

The Ditto Network SDK is designed to simplify the development of blockchain-based applications by providing a suite of tools for managing smart accounts, interacting with the blockchain, and building complex workflows.


## Installation

To install the SDK, use the following commands:

```bash
npm install @ditto-network/core @ditto-network/web3.js web3
```


## Getting Started

Here’s a quick guide to get you started with the Ditto Network SDK:


### Initialize SDK

```javascript
import { Provider, SmartWalletFactory, BrowserStorage } from '@ditto-network/core';
import { EthersSigner, EthersContractFactory } from '@ditto-network/ethers';

const provider = new Provider({
signer: new EthersSigner(signer),
storage: new BrowserStorage(),
contractFactory: new EthersContractFactory(signer),
});
const swFactory = new SmartWalletFactory(provider);

const sw = await swFactory.getDefaultOrCreateVault();
const vaultAddress = sw.getAddress();

console.log('Vault address:', vaultAddress);
```

For more detailed examples, check the [examples](#examples) section.


## Documentation

For comprehensive documentation and details on how to use the Ditto Network, please refer to the main documentation in the [`@ditto-network/core`](https://github.com/dittonetwork/sdk-js/blob/master/packages/core/README.md) package.


### Navigation

- **[`examples/`](https://github.com/dittonetwork/sdk-js/tree/master/examples)**: Contains example projects for Node.js and React.
- **[`packages/`](https://github.com/dittonetwork/sdk-js/tree/master/packages)**: Contains the core packages of the SDK, including `core`, `ethers`, and `web3js`.
- **[`ARCHITECTURE.md`](https://github.com/dittonetwork/sdk-js/blob/master/ARCHITECTURE.md)**: Detailed information about the architecture of the project.
- **[`CHANGELOG.md`](https://github.com/dittonetwork/sdk-js/blob/master/CHANGELOG.md)**: A log of changes and updates to the project.
- **[`CONTRIBUTING.md`](https://github.com/dittonetwork/sdk-js/blob/master/CONTRIBUTING.md)**: Guidelines for contributing to the project.


## Examples

We provide a variety of examples to help you get started with different environments:

- **Node.js Examples**: Located in the [`examples/nodejs-example`](https://github.com/dittonetwork/sdk-js/tree/master/examples/nodejs-example) directory.
- **React Examples**: Located in the [`examples/react-example`](https://github.com/dittonetwork/sdk-js/tree/master/examples/react-example) directory.
- **Sandbox**: Located in the [`examples/sandbox`](https://github.com/dittonetwork/sdk-js/tree/master/examples/sandbox) directory.


## Contributing

Contributions are welcome! Please open an issue or submit a pull request.
Contributions are welcome! Please open an issue or submit a pull request. For more details, refer to our [contributing guidelines](https://github.com/dittonetwork/sdk-js/blob/master/CONTRIBUTING.md).


## Changelog

For a list of changes and updates, see the [CHANGELOG.md](https://github.com/dittonetwork/sdk-js/blob/master/CHANGELOG.md) file.
43 changes: 15 additions & 28 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
Here's an updated version of the README that includes details about all triggers based on the content of the provided files:

---

# @ditto-network/core

A JavaScript SDK for building workflows on the Ditto Network, enabling a Smart Account experience at any level of your project. This SDK provides the necessary tools and adapters for interacting with the blockchain and constructing workflows. You can use the provided adapters or implement your own.
Expand All @@ -20,42 +16,37 @@ A JavaScript SDK for building workflows on the Ditto Network, enabling a Smart A
- [Price-Based Trigger](#price-based-trigger)
- [Time-Based Trigger](#time-based-trigger)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)


## Installation

```bash
npm install @ditto-network/core @ditto-network/web3.js web3
```

or

```bash
yarn add @ditto-network/core @ditto-network/web3.js web3
```

## Getting Started

Here’s a quick guide to get you started with the Ditto Network SDK:


### Initialize SDK

```javascript
const { DittoNetwork } = require('@ditto-network/core');
import { Provider, SmartWalletFactory, BrowserStorage } from '@ditto-network/core';
import { EthersSigner, EthersContractFactory } from '@ditto-network/ethers';

const ditto = new DittoNetwork({
provider: 'https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID',
privateKey: 'YOUR_PRIVATE_KEY'
const provider = new Provider({
signer: new EthersSigner(signer),
storage: new BrowserStorage(),
contractFactory: new EthersContractFactory(signer),
});
const swFactory = new SmartWalletFactory(provider);

// Example function to check account balance
async function getBalance(address) {
const balance = await ditto.getBalance(address);
console.log(`Balance: ${balance}`);
}
const sw = await swFactory.getDefaultOrCreateVault();
const vaultAddress = sw.getAddress();

getBalance('0xYourEthereumAddress');
console.log('Vault address:', vaultAddress);
```

## Examples
Expand All @@ -69,25 +60,21 @@ For Node.js examples, see:

### React

For React examples, see the sandbox project in [examples/sandbox](https://github.com/dittonetwork/sdk-js/tree/master/examples/sandbox).
For React examples, see the sandbox project in [examples/sandbox](https://github.com/dittonetwork/sdk-js/tree/master/examples/sandbox) or [examples/react-example](https://github.com/dittonetwork/sdk-js/tree/master/examples/react-example).

To run the React examples:

```bash
npm run serve
```

or

```bash
yarn serve
```

## Actions and Triggers

### Actions

Actions are the building blocks of a workflow. They are the steps that are executed by triggers. Each action has a configuration that defines how it should be executed. Here is the available action:
Actions are the building blocks of a workflow. They are the steps that are executed by triggers. Each action has a configuration that defines how it should be executed. Here are available actions:


#### Uniswap Swap Action

Expand Down

0 comments on commit 62b0dd7

Please sign in to comment.