# @owdin/filecoin.js

> A JavaScript/TypeScript client library for Filecoin.io's Lotus

Latest version **1.0.2** (published 2021-02-03) · (Apache-2.0 AND MIT) license · 0 weekly downloads

## Install

```sh
npm install @owdin/filecoin.js
pnpm add @owdin/filecoin.js
yarn add @owdin/filecoin.js
bun add @owdin/filecoin.js
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-02-03 |
| First published | 2021-02-02 |
| Weekly downloads | 0 |
| License | (Apache-2.0 AND MIT) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 17 |
| Unpacked size | 894 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | hwnahm |

## Links

- npm: https://www.npmjs.com/package/@owdin/filecoin.js
- Repository: https://github.com/OWDIN/filecoin.js
- Homepage: https://github.com/OWDIN/filecoin.js#readme
- Issues: https://github.com/OWDIN/filecoin.js/issues
- npm.io page: https://npm.io/package/@owdin/filecoin.js

## Dependencies (17)

- [ws](https://npm.io/package/ws.md) ^7.3.1
- [events](https://npm.io/package/events.md) ^3.2.0
- [btoa-lite](https://npm.io/package/btoa-lite.md) ^1.0.0
- [tweetnacl](https://npm.io/package/tweetnacl.md) ^1.0.3
- [websocket](https://npm.io/package/websocket.md) ^1.0.31
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [bitcore-lib](https://npm.io/package/bitcore-lib.md) 8.22.2
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.0.0
- [scrypt-async](https://npm.io/package/scrypt-async.md) ^2.0.1
- [isomorphic-ws](https://npm.io/package/isomorphic-ws.md) ^4.0.1
- [rpc-websockets](https://npm.io/package/rpc-websockets.md) ^5.3.1
- [tweetnacl-util](https://npm.io/package/tweetnacl-util.md) ^0.15.1
- [bitcore-mnemonic](https://npm.io/package/bitcore-mnemonic.md) 8.22.2
- [@nodefactory/filsnap-types](https://npm.io/package/@nodefactory/filsnap-types.md) ^0.2.1
- [@nodefactory/filsnap-adapter](https://npm.io/package/@nodefactory/filsnap-adapter.md) ^0.2.1
- [@ledgerhq/hw-transport-webusb](https://npm.io/package/@ledgerhq/hw-transport-webusb.md) ^5.22.0
- [@zondax/filecoin-signing-tools](https://npm.io/package/@zondax/filecoin-signing-tools.md) ^0.7.1

## Recent versions

- 1.0.2 (latest) — 2021-02-03
- 1.0.1 — 2021-02-03
- 1.0.0 — 2021-02-02
- 1.0.0-beta.1 — 2021-02-02

## README

A JavaScript (and TypeScript) library for interacting with the [Filecoin's](https://filecoin.io) [Lotus](https://github.com/filecoin-project/lotus) node, with support for external signers.

:warning: The library is currently in ALPHA: things will not work or work incorectly, will break and the API will change! :warning:

## Installing

Node:

```bash
npm install --save filecoin.js
```

Browser:

```html
<script type="text/javascript" src="https://unpkg.com/filecoin.js"></script>
<!-- window.FilecoinJs object contains the library exports -->
```
## Using

Node JavaScript/TypeScript:

```javascript
import { HttpJsonRpcConnector, MnemonicWalletProvider } from 'filecoin.js';

(async () => {

  const connector = new HttpJsonRpcConnector({ url: __LOTUS_RPC_ENDPOINT__, token: __LOTUS_AUTH_TOKEN__ });

  const hdWalletMnemonic = 'equip ... young';
  const hdWalletPassword = '...';
  const hdDerivationPath = `m/44'/461'/0'/0/0`;

  const walletProvider = new MnemonicWalletProvider(
    connector,
    hdWalletMnemonic,
    hdWalletPassword,
    hdDerivationPath
  );

  const myAddress = await walletProvider.getDefaultAccount();
  console.log(myAddress);
  // f1zx43cf6qb6rd...

})().then().catch();
```

Browser:

```html
<script type="text/javascript" src="https://unpkg.com/filecoin.js"></script>
<script type="text/javascript">
(async () => {

  const connector = new FilecoinJs.HttpJsonRpcConnector({ url: __LOTUS_RPC_ENDPOINT__, token: __LOTUS_AUTH_TOKEN__ });

  const hdWalletMnemonic = 'equip ... young';
  const hdWalletPassword = async () => await window.prompt(),;
  const hdDerivationPath = `m/44'/461'/0'/0/0`;

  const walletProvider = new FilecoinJs.MnemonicWalletProvider(
    connector,
    hdWalletMnemonic,
    hdWalletPassword,
    hdDerivationPath
  );

  const myAddress = await walletProvider.getDefaultAccount();
  console.log(myAddress);
  // f1zx43cf6qb6rd...

})().then().catch();
</script>
```

## Examples

Sending some FIL to `someAddress`:

```javascript
    const message = await walletProvider.createMessage({
      From: myAddress,
      To: someAddress,
      Value: new BigNumber(42),
    });

    const msgCid = await walletProvider.sendSignedMessage(
      await walletProvider.signMessage(message)
    );
```

Check out the [tests](./tests/) or [examples](./documentation/examples) folders for more usage examples.

## Documentation

As with the rest of the library, the documentation is WIP. As it evolves the [documentation site](http://docs.filecoinjs.surge.sh/) will be updated.

## Contributing

Feel free to join in. All welcome. [Open an issue!](https://github.com/Digital-MOB-Filecoin/filecoin.js/issues)

## License

Dual-licensed under [MIT](./LICENSE-MIT) + [Apache 2.0](./LICENSE-APACHE)

---
_Source: https://npm.io/package/@owdin/filecoin.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
