diff --git a/documentation/src/01-introduction.md b/documentation/src/01-introduction.md index dc8b898..949e692 100644 --- a/documentation/src/01-introduction.md +++ b/documentation/src/01-introduction.md @@ -4,9 +4,9 @@ title: Introduction hide_title: true --- -# Introduction +## Introduction -## What is Filecoin.js +### What is Filecoin.js The filecoin.js library aims to be a complete library for interacting with local or remote Filecoin nodes. diff --git a/documentation/src/02-installing.md b/documentation/src/02-installing.md index 3bf4efd..cd4e15a 100644 --- a/documentation/src/02-installing.md +++ b/documentation/src/02-installing.md @@ -4,33 +4,32 @@ title: Adding Filecoin.js hide_title: true --- -# Adding Filecoin.js +## Adding Filecoin.js In this section, we will show how to add Filecoin.js library to your web application. -## NodeJS +### Node.js + +#### Step 1: Install Filecoin.js -**Step 1:** Install Filecoin.js using [yarn](https://classic.yarnpkg.com/en/package/jest) ```shell +$ npm install filecoin.js // or $ yarn add filecoin.js ``` -or [npm](https://www.npmjs.com/) -```shell -$ npm install filecoin.js -``` -**Step 2:** Import module using node.js require or ES6 synthax +#### Step 2: Import module using node.js require or ES6 syntax + ```javascript -const { } = require("filecoin.js"); +const filecoin = require("filecoin.js"); // or -import { } from "filecoin.js"; +import * as filecoin from "filecoin.js"; ``` -## Browser +### Browser -For using Filecoin.js library in broswer, include the core library in your HTML file and you're ready to go! +For using Filecoin.js library in browser, include the core library in your HTML file and you're ready to go! ```html - + + +``` - const lotusClient = new FilecoinJs.LotusClient(httpConnector); - const version = await lotusClient.common.version(); - console.log(version); +If you run your own node, you will have to provide an argument of type [`JsonRpcConnectionOptions`](https://filecoin-shipyard.github.io/filecoin.js/docs/api/filecoin.js.httpjsonrpcconnector._constructor_) to [`HttpJsonRpcConnector`](https://filecoin-shipyard.github.io/filecoin.js/docs/api/filecoin.js.httpjsonrpcconnector) constructor. -})().then().catch(); - +```js +const httpConnector = new HttpJsonRpcConnector({ + url: __LOTUS_HTTP_RPC_ENDPOINT__, + token: __LOTUS_AUTH_TOKEN__, +}); ``` diff --git a/documentation/src/08-setup-mnemonic-provider.md b/documentation/src/08-setup-mnemonic-provider.md index 261e61c..a054195 100644 --- a/documentation/src/08-setup-mnemonic-provider.md +++ b/documentation/src/08-setup-mnemonic-provider.md @@ -5,10 +5,15 @@ hide_title: true --- # Setup mnemonic provider + Node JavaScript/TypeScript: ```javascript -import { HttpJsonRpcConnector, MnemonicWalletProvider } from 'filecoin.js'; +import { + HttpJsonRpcConnector, + LotusClient, + MnemonicWalletProvider, +} from 'filecoin.js'; (async () => { @@ -27,7 +32,7 @@ import { HttpJsonRpcConnector, MnemonicWalletProvider } from 'filecoin.js'; console.log(myAddress); // f1zx43cf6qb6rd... -})().then().catch(); +})(); ``` Browser: