Connect to Filecoin dapps using Metamask. Manage Filecoin accounts, send FIL to Native and FEVM accounts and enable FEVM transaction insights.
You can install and use filsnap using the Metamask provider.
import { getRequestProvider } from 'filsnap-adapter'
const provider = await getRequestProvider()
// Install filsnap
try {
const result = await provider.request({
method: 'wallet_requestSnaps',
params: {
'npm:filsnap': {
version: '^0.4.0', // Optional, defaults to latest
},
},
})
console.log(result)
/**
{
'npm:filsnap': {
version: '1.0.0',
id: 'npm:filsnap',
enabled: true,
blocked: false,
},
}
*/
} catch (error) {
console.log(error)
}
import { getRequestProvider } from 'filsnap-adapter'
const provider = await getRequestProvider()
// Get filsnap metadata
const result = await provider.request({ method: 'wallet_getSnaps' })
console.log(result)
/**
{
'npm:filsnap': {
version: '1.0.0',
id: 'npm:filsnap',
enabled: true,
blocked: false,
},
}
*/
import { getRequestProvider } from 'filsnap-adapter'
const provider = await getRequestProvider()
// Get filsnap metadata
const result = await provider.request({
method: 'wallet_invokeSnap',
params: { snapId: 'npm:filsnap', method: 'fil_getBalance' },
})
console.log(result)
/**
{
result: '100699819802794525019',
error: null
}
*/
We recommend using filsnap-adapter
to interact with filsnap for a simpler interface. Check the full API documentation here.
fil_configure
- Configure the snap.fil_getBalance
- Get the balance of the connected account.fil_getAddress
- Get the address of the connected account.fil_getPublicKey
- Get the public key of the connected account.fil_getAccountInfo
- Get the account info of the connected account.fil_getGasForMessage
- Get the gas for a message.fil_signMessage
- Sign a message with the connected account.fil_signMessageRaw
- Sign a raw message (string) with the connected account.fil_exportPrivateKey
- Export the private key of the connected account.fil_sendMessage
- Send a message.Check the full RPC methods documentation here.
sequenceDiagram
participant Dapp
box rgb(76, 86, 106) Metamask Extension
participant Metamask
participant filsnap
end
Dapp-)Metamask: connect('npm:filsnap', '0.4.0')
Note over Dapp,Metamask: `wallet_requestSnaps`
Metamask--> Metamask: Install filsnap
Metamask--)filsnap: Connect Dapp to filsnap
activate filsnap
filsnap--)Metamask: Connected
Metamask-)Dapp: filsnap metadata
Dapp-)filsnap: configure({network: 'mainnet'})
Note over Dapp,Metamask: `wallet_invokeSnap` method `fil_configure`
filsnap-)Dapp: filsnap configuration
Dapp-)filsnap: getBalance()
Note over Dapp,Metamask: `wallet_invokeSnap` method `fil_getBalance`
filsnap-)Dapp: 100 FIL (balance)
deactivate filsnap
Read contributing guidelines here.
Dual-licensed: MIT, Apache Software License v2, by way of the Permissive License Stack.