TODO describe actor.ls
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Object>
TODO describe return value
for await ( const actor of fc . actor . ls ( ) )
console . log ( actor )
/*
After first iteration:
{ actorType: 'MinerActor',
address: 'fcqpdd3end3j5hhu7lacxg4vnluu9rxfd3nteezw6',
code: 'zb2rhmciMRS4PBXYBBHssphYKQrbFujVjj1SMyUyN2bU2SKFx',
nonce: 0,
balance: '100',
exports:
{ addAsk: { Params: [Array], Return: [Array] },
commitSector: { Params: [Array], Return: [] },
getKey: { Params: [], Return: [Array] },
getLastUsedSectorID: { Params: [], Return: [Array] },
getOwner: { Params: [], Return: [Array] },
getPeerID: { Params: [], Return: [Array] },
getPower: { Params: [], Return: [Array] },
getProvingPeriodStart: { Params: [], Return: [Array] },
submitPoSt: { Params: [Array], Return: [] },
updatePeerID: { Params: [Array], Return: [] } },
head: 'zDPWYqFD5LSWY8NQR7hWtLU8arYBw6W9eXZ1VvWjzh8YUJfAshx4'
*/
Fetch the default address
address.default([options])
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
The default address
const addr = await fc . address . default ( )
console . log ( addr ) // t1gwlbykvhfrkhrtll43ceiyzgggk7omnololcwpy
TODO describe address.lookup
address.lookup(addr, [options])
Name
Type
Description
addr
String
Address to lookup peer ID for
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
Peer ID for address
List address(es)
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String[]>
Addresses
const addresses = await fc . address . ls ( )
console . log ( addresses ) // [fcqyz3pgq7qpg0nekps597zth57x7xmh4sad7euk0]
TODO describe address.new
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
A newly created address
const addr = await fc . address . new ( )
console . log ( addr ) // fcq7kwnm7mqaynhngfl6qtp03p6jxmyda62zagfek
TODO describe bootstrap.ls
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String[]>
List of bootstrap multiaddrs
const addrs = await fc . boostrap . ls ( )
console . log ( addrs )
/*
[ '/dns4/test.kittyhawk.wtf/tcp/9001/ipfs/QmXq6XEYeEmUzBFuuKbVEGgxEpVD4xbSkG2Rhek6zkFMp4',
'/dns4/test.kittyhawk.wtf/tcp/9002/ipfs/QmXhxqTKzBKHA5FcMuiKZv8YaMPwpbKGXHRVZcFB2DX9XY',
'/dns4/test.kittyhawk.wtf/tcp/9003/ipfs/QmZGDLdQLUTi7uYTNavKwCd7SBc5KMfxzWxAyvqRQvwuiV',
'/dns4/test.kittyhawk.wtf/tcp/9004/ipfs/QmZRnwmCjyNHgeNDiyT8mXRtGhP6uSzgHtrozc42crmVbg' ]
*/
Get heaviest tipset CIDs
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String[]>
Array of String CIDs
const block = await fc . chain . head ( )
console . log ( block )
// [ 'zDPWYqFCrhCRdGa1Z84DBpSQ5rrHphwjs7qHe5uS2LFurdnE6vvF' ]
Dump full block chain
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Object[]>
Iterable of blocks in the blockchain
for await ( const block of fc . chain . ls ( ) )
console . log ( block )
/*
After first iteration:
[ { miner: 'fcq5y65n23xdkcx2ymakflxpxqhkvewnwswp0me52',
ticket: 'BNdhwXA6ty/KdYJ3YY/gZ1CexKRXsDYOpBq0wbK+/kA=',
parents: [ [String] ],
parentWeightNumerator: 'y8q87bOQCQ==',
parentWeightDenominator: 'xpSakwY=',
height: '6hU=',
nonce: 'AA==',
messages: [ [Object] ],
stateRoot: 'zDPWYqFD5LSWY8NQR7hWtLU8arYBw6W9eXZ1VvWjzh8YUJfAshx4',
messageReceipts: [ [Object] ] } ]
*/
Read out data stored on the network
client.cat(cid, [options])
Name
Type
Description
cid
CID
|String
CID of the content to read
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Buffer|UInt8Array>
Content of the file, yields Buffer
objects in Node.js and UInt8Array
objects in the browser
let data = Buffer . alloc ( 0 )
for await ( const chunk of fc . client . cat ( 'QmZPUUg1QVMciR1yYnC2HSFrXyAUwRvpnbx4haYefB2KY3' ) )
data = Buffer . concat ( [ data , chunk ] )
Import data into the local node
client.import(input, [options])
Name
Type
Description
input
Buffer
|String
|AsyncIterable
|TypedArray
|Blob
Data to import. Note, TypedArray
and Blob
supported in browser only.
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
CID of the imported content
From a buffer:
const data = Buffer . from ( 'Hello World!' )
const cid = await fc . client . import ( data )
From a Node.js stream (or async iterable):
const data = fs . createReadStream ( '/path/to/file' )
const cid = await fc . client . import ( data )
List all asks in the storage market
client.listAsks([options])
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Object>
Storage market asks
for await ( const ask of fc . client . listAsks ( ) )
console . log ( ask )
/*
After first iteration:
{ miner: 't2zup5a5rytwissvm6zq74amp4chrnazrl4ev4yii',
price: '0.00000000000001',
expiry: 33329,
id: 4 }
*/
List payments for a given deal
client.payments(dealCid, [options])
Name
Type
Description
dealCid
CID
|String
Channel id from which to list vouchers
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object[]>
List of payments
const cid = 'zDPWYqFCuTNxiwRkt1iDJWEy6qKPGCunMGHrP1ojsMrZDWKYsgzF'
const payments = await fc . client . payments ( cid )
console . log ( payments )
/*
[
{
"channel": 0,
"payer": "t1bcvxo4ztdkukjmrsjvc5d4w24cl55vvbrssspyy",
"target": "t1uo4nzu44apoclkbjbbvc4f3irbptg3ctjq44wiq",
"amount": "25000",
"validAt": 8,
"condition": null,
"signature": "1My76149fPIulbdO/DKlkUBMMSLwGYSw2XmVKXq3HrxMG5kkmBgsaPZ/DzdxiOWX5kdnXJ++AFQqsmWHd5dtOwE="
}
]
*/
client.proposeStorageDeal
Propose a storage deal with a storage miner
client.proposeStorageDeal(miner, cid, askId, time, [options])
Name
Type
Description
miner
String
Address of miner to send storage proposal
cid
String
CID of the data to be stored
askId
String
ID of ask for which to propose a deal
time
Number
|String
Time in blocks (about 30 seconds per block) to store data. For example, storing for 1 day (2 blocks/min * 60 min/hr * 24 hr/day) = 2880 blocks.
options
Object
Optional options
options.allowDuplicates
Boolean
Allows duplicate proposals to be created. Unless this flag is set, you will not be able to make more than one deal per piece per miner. This protection exists to prevent erroneous duplicate deals. This parameter is not required.
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
Storage deal
const miner = 't2u2r6nyaxdspozci5t2i2xtfw23lxa35rvkul7di'
const cid = 'QmV9mkND7mvWim77R669UCLg1DgYzqiX1NsXtj7GSydzD6'
const askId = '0'
const time = 2800 // 1 day
const storageDealProposal = await fc . client . proposeStorageDeal ( miner , cid , askId , time )
// with optional flag to allow duplicates
const storageDealProposal = await fc . client . proposeStorageDeal ( miner , cid , askId , time , { allowDuplicates : true } )
/*
{
"state": 3,
"message": "",
"proposalCid": "zDPWYqFCz8vQRUnFVsbdXPAWTRuRBLaPncKLLSqd7cNF3Bd2NQT5",
"proofInfo": null,
"signature": "c2lnbmF0dXJycmVlZQ=="
}
*/
Query a storage deal's status
client.queryStorageDeal(dealCid, [options])
Name
Type
Description
dealCid
String
CID of deal to query
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
Storage deal
const dealCid = 'zDPWYqFD8CNXu7Mo9qPSUANbTK2vi9vJBnvavF9S1pVGPHafVHpT'
const storageDeal = await fc . client . queryStorageDeal ( dealCid )
console . log ( storageDeal )
/*
{
"state": 7,
"message": "",
"proposalCid": "zDPWYqFD8CNXu7Mo9qPSUANbTK2vi9vJBnvavF9S1pVGPHafVHpT",
"proofInfo":
{
"sectorID": 1,
"commD":"mkgOa7RCAYNHgUqsWmNR0MjAkzNMZM46ZPPuLonPsDk=",
"commR":"gMGjsTgYFeXSFq3Vaqf2Nm2rhMV/nJ17nmZEPMeCs1I=",
"commRStar":"87+U6/0jhvfBtauei+LG//bDpsNqlRa9Yguv+VSPHAE=",
"commitmentMessage": "zDPWYqFCtHkWNkE2p6t6TeV1sPP5kbnKc5ajUhMVV8xvrw1u5F1R",
"pieceInclusionProof": "EiAbbOy4pChsCYqFYA6qJaUJYStlnwYMdQPHZX7YBkVXDD6vgmGTPnWrcdA9M0oAXQCzOq735YKySLUoTI6pAw=="
},
"signature": "c2lnbmF0dXJycmVlZQ=="
}
*/
Get config values
config.get(key, [options])
Name
Type
Description
key
String
Dot separated key to config value to retrieve
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise
The current config value
const value = await fc . config . get ( 'bootstrap.addresses' )
console . log ( value )
/*
["/dns4/nightly.kittyhawk.wtf/tcp/9000/ipfs/Qmd6xrWYHsxivfakYRy6MszTpuAiEoFbgE1LWw4EvwBpp4",
"/dns4/nightly.kittyhawk.wtf/tcp/9001/ipfs/QmXq6XEYeEmUzBFuuKbVEGgxEpVD4xbSkG2Rhek6zkFMp4",
"/dns4/nightly.kittyhawk.wtf/tcp/9002/ipfs/QmXhxqTKzBKHA5FcMuiKZv8YaMPwpbKGXHRVZcFB2DX9XY",
"/dns4/nightly.kittyhawk.wtf/tcp/9003/ipfs/QmZGDLdQLUTi7uYTNavKwCd7SBc5KMfxzWxAyvqRQvwuiV",
"/dns4/nightly.kittyhawk.wtf/tcp/9004/ipfs/QmZRnwmCjyNHgeNDiyT8mXRtGhP6uSzgHtrozc42crmVbg']
*/
Set a config value
config.set(key, value, [options])
Name
Type
Description
key
String
Dot separated key to config property name
value
?
Value to set for the config value (must be JSON stringifyable)
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise
The set config value
const value = await fc . config . set ( 'api.address' , '/ip4/127.0.0.1/tcp/3453' )
console . log ( value )
/*
/ip4/127.0.0.1/tcp/3453
*/
Get a DAG node by its CID
Name
Type
Description
cid
CID
|String
CID of the DAG node to get
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object|Buffer|Blob>
The DAG node. If the server returns Content-Type: 'application/json'
then the response is parsed into a JS object. Otherwise the raw Buffer
(in Node.js) or Blob
(in the browser) are returned.
const UnixFs = require ( 'ipfs-unixfs' )
const input = Buffer . from ( 'Hello World!' )
const cid = await fc . client . import ( input )
const node = await fc . dag . get ( cid )
// Extract the raw data from the UnixFs DAG node
const output = UnixFs . unmarshal ( Buffer . from ( output . data , 'base64' ) ) . data
console . log ( output . toString ( ) ) // Hello World!
Find a peer given a peerId.
dht.findPeer(peerId, [options])
Name
Type
Description
peerId
String
ID of peer to find
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<String>
Multiaddresses of a given peer.
const peers = await fc . swarm . peers ( )
const peerId = peers [ 0 ] . addr . getPeerId ( )
for await ( const addr of fc . dht . findPeer ( peerId ) )
console . log ( addr )
/*
[ '/ip4/3.90.230.176/tcp/49996',
'/ip4/3.90.230.176/tcp/49917',
'/ip4/3.90.230.176/tcp/58302',
'/ip4/3.90.230.176/tcp/9004',
'/ip4/3.90.230.176/tcp/49889',
'/ip4/3.90.230.176/tcp/49872',
'/ip4/3.90.230.176/tcp/57292',
'/ip4/172.19.0.14/tcp/9000',
'/ip4/3.90.230.176/tcp/46177',
'/ip4/127.0.0.1/tcp/9000'
*/
Find peers that can provide a given key's value.
dht.findProvs(key, [options])
Name
Type
Description
key
String
The key whose provider Peer IDs are output
options
Object
Optional options
options.numProviders
Boolean
The max number of providers to find. Default: 20
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Object>
Responses from peers documenting the providers that provide the value.
for await ( const res of fc . dht . findProvs ( 'QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH' ) )
console . log ( res )
/*
Example iteration output:
{ type: 1,
responses:
[ { id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] },
{ id: [String], addrs: [Array] } ],
id: 'QmRCrwBopruk3dihfu9njyZ2J88VvCJG4JEnmhNku47RCR'
*/
Get the identity of the Filecoin node
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<{ id<String>, addresses<String[]> }>
TODO describe return value
const { id, addresses } = await fc . id ( )
console . log ( { id, addresses } )
/*
{ id: 'QmVESp5X5EtRXGrDBqHzZ1Hd22nSh5QLtw8BozGNu9dWef',
addresses:
[ '/ip4/127.0.0.1/tcp/6000/ipfs/QmVESp5X5EtRXGrDBqHzZ1Hd22nSh5QLtw8BozGNu9dWef',
'/ip4/192.168.1.132/tcp/6000/ipfs/QmVESp5X5EtRXGrDBqHzZ1Hd22nSh5QLtw8BozGNu9dWef' ] }
*/
Set the logging level for a subsystem or all subsystems
log.level(level, [options])
Name
Type
Description
level
String
Log level to set. Available levels: debug, info, warning, error, fatal
options
Object
Optional options
options.subsystem
String
Subsystem to set the log level for. See log.ls
for available subsystems
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
Confirmation message
Set log level for all subsystems:
const msg = await fc . log . level ( 'debug' )
console . log ( msg ) // "Changed log level of all subsystems to: debug"
Set log level for "ping" subsystem:
const msg = await fc . log . level ( 'debug' , { subsystem : 'ping' } )
console . log ( msg ) // "Changed log level of 'ping' to 'debug'"
List the logging subsystems
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String[]>
The available subsystems
const subsystems = await fc . log . ls ( )
console . log ( subsystems )
/*
[ 'commands/log',
'fps',
'net.bootstrap',
'messageimpl',
'peerstore',
'swarm2',
'dht.pb',
'autorelay',
'engine',
'eventlog',
'blockstore',
'keystore',
'transport',
'types',
'nat',
'bstestnet',
'sectorbuilder',
'/fil/hello',
'mplex',
'addrutil',
'cmds/http',
'cmds/cli',
'autonat-svc',
'node',
'metrics',
'pubsub',
'chain.store',
'p2p-config',
'basichost',
'boguskey',
'mocknet',
'mockrouter',
'routing/record',
'providers',
'reuseport-transport',
'net/identify',
'secio',
'repo',
'ping',
'peerqueue',
'pathresolv',
'chain.syncer',
'chunk',
'bitswap_network',
'lock',
'stream-upgrader',
'tcp-tpt',
'relay',
'/fil/retrieval',
'/fil/storage',
'cmds',
'porcelain',
'discovery',
'table',
'dht',
'autonat',
'routedhost',
'bitswap',
'blockservice',
'consensus.expected',
'mqueue',
'mining' ]
*/
Tail the logs
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Object>
Log entries
for await ( const entry of fc . log . tail ( ) )
console . log ( entry )
Wait for a message to appear in a mined block
message.wait(messageCid, [options])
Name
Type
Description
messageCid
CID
|String
CID of the message to wait for
options
Object
Optional options
options.message
Boolean
Print the whole message. Default: true.
options.receipt
Boolean
Print the whole message receipt. Default: true.
options.return
Boolean
Print the return value from the receipt. Default: false.
options.signal
AbortSignal
A signal that can be used to abort the request
options.timeout
String
Maximum time to wait for message. e.g., 300ms, 1.5h, 2h45m. Default: 10m.
Type
Description
Promise<Object>
Message contents
const msg = await fc . message . wait ( 'zdpuAm8mTU17dB5mckEDSNXFtvuxVESUhKivSLCWw1kMZjdK9' )
Create a new file miner with FIL
Issues a new message to the network to create the miner, then waits for the message to be mined as this is required to return the address of the new miner.
Collateral will be committed at the rate of 0.001FIL per sector. When the miner's collateral drops below 0.001FIL, the miner will not be able to commit additional sectors.
miner.create(collateral, [options])
Name
Type
Description
collateral
Number
|String
The amount of collateral, in FIL.
options
Object
Optional options
options.sectorSize
String
Size of the sectors which this miner will commit, in bytes.
options.from
String
Address to send from
options.peerId
String
Base58-encoded libp2p peer ID that the miner will operate.
options.gasPrice
Number
|String
Price (FIL e.g. 0.00013) to pay for each GasUnits consumed mining this message.
options.gasLimit
Number
|String
Maximum number of GasUnits this message is allowed to consume.
options.preview
Boolean
Preview the Gas cost of this command without actually executing it.
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<?>
TODO
const res = await fc . miner . create ( 100 , {
gasPrice : 0.1 ,
gasLimit : 300 ,
from : 't1afotrik6r7s4mcm5oeay6vc7qombbxjqplkw4ka'
} )
console . log ( res )
Stop mining operations
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
Confirmation message
const msg = await fc . mining . stop ( )
console . log ( msg ) // Stopped mining
Send echo request packets to p2p network members
Name
Type
Description
peerId
CID
|String
ID of peer to be pinged
options
Object
Optional options
options.count
Number
Number of ping messages to send. Default: 10
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<{ success<Boolean>, text<String>, time<Number> }>
Async iterable of pong messages received by the node
const peers = await fc . swarm . peers ( )
const peerId = peers [ 0 ] . addr . getPeerId ( )
for await ( const pong of fc . ping ( peerId ) )
console . log ( pong )
/*
After first iteration:
{ success: true, text: '', time: 187.54 }
*/
retrievalClient.retrievePiece
Read out piece data stored by a miner on the network
retrievalClient.retrievePiece(miner, cid, [options])
Name
Type
Description
miner
String
Retrieval miner actor address
cid
CID
|String
Content identifier of piece to read
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
AsyncIterable<Buffer|UInt8Array>
Content of the file, yields Buffer
objects in Node.js and UInt8Array
objects in the browser
const pieceData = fc . retrievalClient . retrievePiece (
't2u2r6nyaxdspozci5t2i2xtfw23lxa35rvkul7di' ,
'QmSB6t4fVfE4fZ46EFBodtK89RJaCRTtPRaEYFx8EQxh8a'
)
let data = Buffer . alloc ( 0 )
for await ( const chunk of pieceData )
data = Buffer . concat ( [ data , chunk ] )
Show a filecoin block by its CID
show.block(cid, [options])
Name
Type
Description
cid
CID
|String
CID of block to show
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
The blockchain block
const block = await fc . show . block ( 'zDPWYqFCutuHwRZhGXzji9L4eHeoFxxNCxCruGjWje36aAvbK2XV' )
console . log ( block )
/*
{ miner: '',
ticket: null,
parents: 'zDPWYqFCtf5awkxnZbpurnQFvsrafnv4nJbP8UkAHD8GCf8T2Sz4',
parentWeight: 'AA==',
height: 'AA==',
nonce: 'AA==',
messages: null,
stateRoot: 'zdpuAm8mTU17dB5mckEDSNXFtvuxVESUhKivSLCWw1kMZjdK9',
messageReceipts: null,
proof:
[ 0,
0,
0,
0,
0,
0,
... 92 more items ] }
*/
Get bandwidth usage statistics
stats.bandwidth([options])
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
Current bandwidth usage stats
const stats = await fc . stats . bandwidth ( )
console . log ( stats )
/*
{ totalIn: 7962607306,
totalOut: 5437567180,
rateIn: 1757169.0307054976,
rateOut: 1066315.9253809578 }
*/
Open a connection to a given address
swarm.connect(addr, [options])
Name
Type
Description
addr
String
|Multiaddr
|String[]
|Multiaddr[]
Address(es) to connect to
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object[]>
List of connection results
const res = await fc . swarm . connect ( '/ip4/192.168.1.1/tcp/6000/ipfs/QmQbd6WxZ3pwcwWn21MvgH1zH4m8hk148kTfoB6BNFa5hK' )
console . log ( res )
/*
[ { peer: 'QmQbd6WxZ3pwcwWn21MvgH1zH4m8hk148kTfoB6BNFa5hK',
success: true } ]
*/
List peers with open connections
Name
Type
Description
options
Object
Optional options
options.latency
Boolean
Return information about latency for each peer
options.streams
Boolean
Return information about open streams for each peer
options.verbose
Boolean
Return all extra information
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object[]>
List of peer info
const peers = await fc . swarm . peers ( { verbose : true } )
console . log ( peers . map ( p => ( { ...p , addr : p . addr . toString ( ) } ) ) )
/*
{ addr:
'/ip4/67.180.60.249/tcp/35645/ipfs/QmNTS7MeGJYu4StMn1EmnV6XyX4JhxZPNrHrdcApLNk1YA',
streams: [ { protocol: '/fil/hello/1.0.0' },
{ protocol: '/fil/hello/1.0.0' },
{ protocol: '/fil/kad/1.0.0' },
{ protocol: '/floodsub/1.0.0' },
{ protocol: '/floodsub/1.0.0' } ],
latency: 'n/a',
muxer: '' } ]
*/
Get the version of the Filecoin node
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
TODO describe return value
const version = await fc . version ( )
console . log ( version )
/*
{ commit: '4e75ee9b601525c45eb255d80ccb73de35102c6d' }
*/
Get the wallet address(es)
wallet.addrs.ls([options])
Name
Type
Description
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String[]>
TODO describe return value
const addresses = await fc . wallet . addrs . ls ( )
console . log ( addresses )
/*
['fcqu4uhfnuvwu4yf647lgatjftht5pyn44yxxfc5k']
*/
Lookup the balance of a given wallet
wallet.balance(addr, [options])
Name
Type
Description
addr
String
Address of wallet to lookup balance of
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<String>
Balance of the wallet
const balance = await fc . wallet . balance ( 'fcqqr00e38ge3vr90xx7x46gj7hq3dxcl09us08e' )
console . log ( balance ) // 6900
Export key information for wallets
wallet.export(addr, [options])
Name
Type
Description
addr
String
|String[]
Address(es) of wallet(s) to export
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
Exported key info
Single:
const info = await fc . wallet . export ( 'fcqqr00e38ge3vr90xx7x46gj7hq3dxcl09us08e' )
console . log ( info )
/*
{
keyInfo: [
{
privateKey: 'RxOfKlALxw8+XCaHQGaJfpXRWweYl+/xdIxVQfJTaTU=',
curve: 'secp256k1'
}
]
}
*/
Multiple:
const info = await fc . wallet . export ( [
'fcqqr00e38ge3vr90xx7x46gj7hq3dxcl09us08e' ,
'fcq5y65n23xdkcx2ymakflxpxqhkvewnwswp0me52'
] )
console . log ( info )
/*
{
keyInfo: [
{
privateKey: 'RxOfKlALxw8+XCaHQGaJfpXRWweYl+/xdIxVQfJTaTU=',
curve: 'secp256k1'
},
{
privateKey: 'rZ7hdys60Rk5+kab9ZuUJ87o6zLgyYgOqP1lHEAYgwo=',
curve: 'secp256k1'
}
]
}
*/
import a wallet with KeyInfo
wallet.import(keyInfo, [options])
Name
Type
Description
addr
KeyInfo
|KeyInfo[]
KeyInfo(s) to import
options
Object
Optional options
options.signal
AbortSignal
A signal that can be used to abort the request
Type
Description
Promise<Object>
imported address(es)
Single:
const keyInfo = { "privateKey" :"pdHwTOrJXnAGvQ0861k66xRsiT7N3Ms8IGte3nT837E=" , "curve" :"secp256k1" }
const res = await fc . wallet . import ( keyInfo )
console . log ( res . addresses )
// [ 't1b3keswmeuk4tipp5egjbk3aoag56g5zd3cle2va' ]
Multiple:
const keyInfo = [
{ "privateKey" :"pdHwTOrJXnAGvQ0861k66xRsiT7N3Ms8IGte3nT837E=" , "curve" :"secp256k1" } ,
{ "privateKey" :"Wxvp929XNPFVPPefsYJqpOuAnoXceh+P6tNq5pEmqcc=" , "curve" :"secp256k1" }
]
const res = await fc . wallet . import ( keyInfo )
console . log ( res . addresses )
// [ 't1b3keswmeuk4tipp5egjbk3aoag56g5zd3cle2va', 't1dktsc463xl3e3fq7bgjg6h2zcmhftvqfw7juqea' ]