From 62b0dd74cb75f8978fc19c48cee9c0c4f0ee0286 Mon Sep 17 00:00:00 2001 From: extg3 Date: Mon, 10 Jun 2024 23:13:25 +0100 Subject: [PATCH] feat(global): add getting started section for root README --- README.md | 80 ++++++++++++++++++++++++++++++++++++++++- packages/core/README.md | 43 ++++++++-------------- 2 files changed, 94 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 2cce93b..f63596a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/packages/core/README.md b/packages/core/README.md index a5915fa..77fed17 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -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. @@ -20,8 +16,7 @@ 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 @@ -29,33 +24,29 @@ A JavaScript SDK for building workflows on the Ditto Network, enabling a Smart A 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 @@ -69,7 +60,7 @@ 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: @@ -77,17 +68,13 @@ To run the React examples: 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