webnative-filecoin
v0.6.11
Published
Fission Webnative Filecoin SDK
Downloads
31
Keywords
Readme
Webnative Filecoin
Send secure Filecoin transactions from the browser.
Use Fission's webnative SDK to store keys and securely send transactions by aggregating signatures between the in-browser key and a cosigning server that depends on UCANs (user-controlled, distributed auth tokens).
Get started
import { getWallet, getWalletFromKey, DEFAULT_KEY_PERMISSION } from 'webnative-filecoin'
import * as wn from 'webnative'
// Initialize webnative
const state = await wn.initialise({
permissions: {
app: {
name: 'AppName',
creator: 'Creator'
},
fs: {
// make sure to request permission for the keychain path
privatePaths:[DEFAULT_KEY_PERMISSION] // Defaults to `private/Keychain/fil-cosigner`
publicPaths:[]
}
}
})
// Do necessary state checks / redirects
// Pass the filesystem to webnative-filecoin as well as your implementation of wn
const wallet = await getWallet(state.fs, wn) // if using a keyName other than the default, pass that as a third param
// Fund the Fission storage provider
const receipt = await wallet.fundProvider(1)
// Send FIL to an arbitrary address
const receipt2 = await wallet.send('t1hx...', 1)
// Wait for tx to be confirmed on Filecoin network
const verifiedReceipt = await wallet.waitForReceipt(receipt.messageId)
Development
# install dependencies
yarn
# build
yarn build
# build w/ reloading
yarn dev
# test
yarn test
# test w/ reloading
yarn test:watch