Skip to content

Getting Started

iso-filecoin is a Filecoin Standard Library that provides a set of lightweight, performant and type-safe Javascript modules.

It provides core utilities, abstractions and types for primitives such as: RPC, Signature, Address, Token, Chain, Wallet and more.

Used by the Metamask Filecoin Wallet and Ledger Live Filecoin app.

Installation

Install the required packages.

Terminal window
pnpm add iso-filecoin

Usage

import {
class Message

Filecoin Message class

Message
} from 'iso-filecoin/message'
import {
class Token

Class to work with different Filecoin denominations.

Token
} from 'iso-filecoin/token'
import * as
import Wallet
Wallet
from 'iso-filecoin/wallet'
const
const mnemonic: string
mnemonic
=
import Wallet
Wallet
.
function generateMnemonic(): string

Generate mnemonic

generateMnemonic
()
const
const account: {
type: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/signature").SignatureType;
address: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/types").IAddress;
publicKey: Uint8Array;
path: string;
privateKey: Uint8Array;
}
account
=
import Wallet
Wallet
.
function accountFromMnemonic(mnemonic: string, type: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/signature").SignatureType, path: string, password?: string, network?: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/types").Network): {
type: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/signature").SignatureType;
address: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/types").IAddress;
publicKey: Uint8Array;
path: string;
privateKey: Uint8Array;
}

Get HD account from mnemonic

@parammnemonic

@paramtype

@parampath

@parampassword

@paramnetwork

accountFromMnemonic
(
const mnemonic: string
mnemonic
,
'SECP256K1',
"m/44'/461'/0'/0/0"
)
const
const address: string
address
=
const account: {
type: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/signature").SignatureType;
address: import("/opt/buildhome/repo/packages/iso-filecoin/dist/src/types").IAddress;
publicKey: Uint8Array;
path: string;
privateKey: Uint8Array;
}
account
.
address: IAddress
address
.
IAddress.toString: () => string
toString
()
// 'f17levgrkmq7jeloew44ixqokvl4qdozvmacidp7i'
const
const msg: Message
msg
= new
new Message(msg: PartialMessageObj): Message

@parammsg

Message
({
from: string
from
:
const address: string
address
,
to: string
to
: 'f4...',
value: string
value
:
class Token

Class to work with different Filecoin denominations.

Token
.
Token.fromFIL(val: Value): Token

@paramval

fromFIL
(1).
Token.toAttoFIL(): Token
toAttoFIL
().
Token.toString(base?: number | undefined): string

Serialize the number to a string using the given base.

@parambase

toString
()
})