SnapSync
Snap developers can easily integrate SnapSync into their
snaps to enable data persistence on IPFS.
Add SnapSync to your snap manifest to allow your snap to work with third-party snaps using RPC calls. Here's an example manifest from the Pet Fox snap.
const IPFS_SNAP_ID = 'npm:@ae-studio/snapsync'
Send messages to SnapSync to persist and retrieve data from IPFS. Here's an example of
getting and persisting the state.
// Get latest data from IPFS, or null if not found
await snap.request({
method: 'wallet_invokeSnap',
params: {
snapId: IPFS_SNAP_ID,
request: {method: 'get' },
},
});
// Persist state in IPFS
await snap.request({
method: 'wallet_invokeSnap',
params: {
snapId: IPFS_SNAP_ID,
request: { method: 'set', params: state }
}
});
Your snap is automatically identified in the request messages. If the user doesn't have SnapSync installed, they will be prompted to install it and setup the integration.
That's all you need to do! For more information, please check the GitHub repository.