Package Exports
- @ganache/filecoin
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ganache/filecoin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@ganache/filecoin
This package provides Ganache's Filecoin client implementation.
Table of Contents
CLI Usage
To use Filecoin-flavored Ganache via the CLI, follow the below instructions:
Remove any existing version of Ganache CLI
npm uninstall --global ganache-cli npm uninstall --global ganache
Install the
ganachepackage globally with thefilecointag (note that we're not installing the oldganache-clipackage)npm install --global ganache@filecoin
Install the
@ganache/filecoingloballynpm install --global @ganache/filecoin
Run Filecoin-flavored Ganache
ganache filecoin
See available options
ganache filecoin --helpYou can use Ethereum-flavored Ganache still
# Running "ganache" defaults to Ethereum ganache # or you can specify ethereum as the flavor ganache ethereum
NodeJS Usage
Install
If you're using Filecoin-flavored Ganache as a NodeJS dependency, you need to make sure you install both the ganache package (with the filecoin tag) and the @ganache/filecoin package.
# install the base Ganache package
npm install ganache@filecoin
# install the Filecoin peer dependency package
npm install @ganache/filecoinUsage
In your code, you will use the ganache package directly to instantiate the Filecoin flavor. Below is an example on how to do that with the default options.
import Ganache from "ganache";
const startupOptions = {
flavor: "filecoin";
}
// Provider usage
const provider = Ganache.provider(startupOptions);
const result = await provider.send({
jsonrpc: "2.0",
id: "0",
method: "Filecoin.Version",
params: []
});
// Server usage (starts up a HTTP and WebSocket server)
const server = Ganache.server(startupOptions);
server.listen(7777, () => {
console.log("Lotus RPC endpoint listening at http://localhost:7777/rpc/v0");
});Startup Options
See available startup options in @ganache/filecoin-options.
Supported RPC Methods
@ganache/filecoin does not support all of the RPC methods implemented within Lotus; further, it implements some custom methods. Below is a list of each method.
Ganache Specific RPC Methods
Ganache.MineTipset: Manually mine a tipset immediately. Mines even if the miner is disabled. No parameters.Ganache.EnableMiner: Enables the miner. No parameters.Ganache.DisableMiner: Disables the miner. No parameters.Ganache.MinerEnabled: The current status on whether or not the miner is enabled. The initial value is determined by the optionminer.mine. If true, then auto-mining (miner.blockTime = 0) and interval mining (miner.blockTime > 0) will be processed. If false, tipsets/blocks will only be mined withGanache.MineTipset. No parameters.Ganache.MinerEnabledNotify: A subscription method that provides an update whenever the miner is enabled or disabled. No parameters.Ganache.GetDealById: Retrieves an internalDealInfoby itsDealID. Takes a single parameter,DealID, of typenumber.
Supported Lotus RPC methods
Filecoin.ChainGetBlockFilecoin.ChainGetBlockMessagesFilecoin.ChainGetGenesisFilecoin.ChainGetMessageFilecoin.ChainGetTipSetFilecoin.ChainGetTipSetByHeightFilecoin.ChainHeadFilecoin.ChainNotifyFilecoin.ClientFindDataFilecoin.ClientGetDealInfoFilecoin.ClientGetDealStatusFilecoin.ClientGetDealUpdatesFilecoin.ClientListDealsFilecoin.ClientRetrieveFilecoin.ClientStartDealFilecoin.ID- Returns a hardcoded ID ofbafzkbzaced47iu7qygeshb3jamzkh2cqcmlxzcpxrnqsj6yoipuidor523jygFilecoin.MpoolBatchPush- FIL transfer only (Method = 0)Filecoin.MpoolBatchPushMessage- FIL transfer only (Method = 0)Filecoin.MpoolClearFilecoin.MpoolGetNonceFilecoin.MpoolPendingFilecoin.MpoolPush- FIL transfer only (Method = 0)Filecoin.MpoolPushMessage- FIL transfer only (Method = 0)Filecoin.MpoolSelectFilecoin.StateListMinersFilecoin.StateMinerInfoFilecoin.StateMinerPowerFilecoin.WalletBalanceFilecoin.WalletDefaultAddressFilecoin.WalletDeleteFilecoin.WalletExportFilecoin.WalletHasFilecoin.WalletImport-KeyInfo.Typeof typesecpk1-ledgeris not supportedFilecoin.WalletListFilecoin.WalletNew-KeyInfo.Typeof typesecpk1-ledgeris not supportedFilecoin.WalletSetDefaultFilecoin.WalletSignFilecoin.WalletSignMessageFilecoin.WalletValidateAddressFilecoin.WalletVerifyFilecoin.ActorAddressFilecoin.Version