A Substrate pallet to bridge from Filecoin to any blockchain built using the Substrate framework, including Polkadot parachains.
The detailed specs are available here
We recommend to use our docker image for the quick start of the features filecoindot provide
# NOTE: If you are trying to run `filecoindot-template` on mac with apple silicon, please run `cargo build --release` to build the binary yourselves,
# then run `./target/release/filecoindot-template --tmp --dev --unsafe-ws-external --unsafe-rpc-external --rpc-methods unsafe`
#
# see https://docs.docker.com/desktop/mac/apple-silicon/#known-issues
docker run -p 9933:9933 -p 9944:9944 ghcr.io/chainsafe/filecoindot-template --tmp --dev --unsafe-ws-external --unsafe-rpc-external --rpc-methods unsafe
After the node start emiting logs, run
# /filecoindot
sh scripts/setup.sh
to setup our filecoindot node, the setup config by default is
{
"filecoindotRpc": ["https://api.node.glif.io"],
"id": "fdot",
"suri": "brief outside human axis reveal boat warm amateur dish sample enroll moment",
"ws": "ws://0.0.0.0:9944"
}
Here we need to configure filecoindot into our runtime first, see substrate-node-example for detail.
Generate an account with subkey for our offchain worker first
$ subkey generate
Secret phrase `brief outside human axis reveal boat warm amateur dish sample enroll moment` is account:
Secret seed: 0x4ebb14295f95e62a865a457629a8e6d96ef5f3cf1896a9624d2e91e09f4cdc65
Public key (hex): 0x0676a4b19c66b31e12d15fe31ccbc775d3d2cda6e1c8686e395118f808eaa118
Account ID: 0x0676a4b19c66b31e12d15fe31ccbc775d3d2cda6e1c8686e395118f808eaa118
SS58 Address: 5CDBPWWtnLTqSUSNvB5BGYMs23Vs8dDHwWpjWpebBRErZM9W
and then, post your account to the node
curl -X POST -H "Content-type: application/json" http://localhost:9933 -d '
{
"method": "author_insertKey",
"jsonrpc": "2.0",
"id": 0,
"params": [
"fdot",
"brief outside human axis reveal boat warm amateur dish sample enroll moment",
"0x0676a4b19c66b31e12d15fe31ccbc775d3d2cda6e1c8686e395118f808eaa118"
]
}
'
Make sure you transfer some funds to this account. E.g using polkadot.js/apps and using some funds from the dev accounts.
curl -X POST -H "Content-type: application/json" http://localhost:9933 -d '
{
"method": "filecoindot_setRpcEndpoint",
"jsonrpc": "2.0",
"id": 0,
"params": [ ["https://api.node.glif.io"] ]
}
'
If you can see the logs below in your terminal
2021-10-31 21:58:55 Running in --dev mode, RPC CORS has been disabled.
2021-10-31 21:58:55 Substrate Node
2021-10-31 21:58:55 ✌️ version 3.0.0-9e5d007-aarch64-macos
2021-10-31 21:58:55 ❤️ by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021
2021-10-31 21:58:55 📋 Chain specification: Development
2021-10-31 21:58:55 🏷 Node name: fuzzy-doctor-8068
2021-10-31 21:58:55 👤 Role: AUTHORITY
2021-10-31 21:58:55 💾 Database: RocksDb at /Users/clearloop/Library/Application Support/node-template/chains/dev/db
2021-10-31 21:58:55 ⛓ Native runtime: node-template-100 (node-template-1.tx1.au1)
2021-10-31 21:58:55 Using default protocol ID "sup" because none is configured in the chain specs
2021-10-31 21:58:55 🏷 Local node identity is: 12D3KooWPY6sbvMAryQkXRDKiApkd75Ak8x7cbgEqtiEzFxb5kQF
2021-10-31 21:58:55 could not parse an IP from hosts file
2021-10-31 21:58:57 📦 Highest known block at #168
2021-10-31 21:58:57 〽️ Prometheus exporter started at 127.0.0.1:9615
2021-10-31 21:58:57 Listening for new connections on 127.0.0.1:9944.
2021-10-31 21:59:00 🙌 Starting consensus session on top of parent 0x6b98f8856f41abfb45da878188aaff1419c1cb6bbb8a56a346e9f1f39613a1a4
2021-10-31 21:59:00 🎁 Prepared block for proposing at 169 [hash: 0x9f3941c44fdacc7f240b0471c97cd61e5010377619501285999ab0ff4d0edbbc; parent_hash: 0x6b98…a1a4; extrinsics (1): [0x1dd1…1b8b]]
2021-10-31 21:59:00 🔖 Pre-sealed block for proposal at 169. Hash now 0x53480ec65b6b2c13126a96c62089af0244a570ba961efdd0d377a44df12a5a5b, previously 0x9f3941c44fdacc7f240b0471c97cd61e5010377619501285999ab0ff4d0edbbc.
2021-10-31 21:59:00 ✨ Imported #169 (0x5348…5a5b)
2021-10-31 21:59:00 bootstrap filecoindot ocw with filecoin rpc endpoint http://user:pass@infura.io
the filecoindot offchain worker has been set up!
In the provided substrate-node-example, we configured the type ManagerOrigin
of filecoindot
with frame_system::EnsureRoot<AccountId>
, so here we need to add_relayer
with sudo access.
For setting relayer in polkadot.js.org/apps
, we need to click Developer -> Sudo -> filecoindot -> add_relayer
and choose an account to be the new relayer.
Or with @polkadot/api, you can use the code below:
import { ApiPromise, WsProvider } from "@polkadot/api";
import { rpc, types } from "@chainsafe/fileconidot-types";
import { Keyring } from "@polkadot/keyring";
(async () => {
// setup the api
const provider = new WsProvider("http://0.0.0.0:9944");
const api = await ApiPromise.create({ provider, types, rpc });
// setup the signer
const keyring = new Keyring({ type: "sr25519" });
const signer = keyring.addFromUri("//Alice");
// execute the `add_relayer` extrinsic
const tx_hash = await api.tx.sudo
.sudo(this._.tx.filecoindot.addRelayer(signer.address))
.signAndSend(signer);
})();
See the example runtime for a full example showing how to integrate the pallet into a substrate runtime.
Once you have the node and container running you can test FSB going on https://filecoindot.chainsafe.io/ you will need to have the polkadot.js extention running and the substrate node https://polkadot.js.org/apps/#/explorer
We take all security issues seriously, if you believe you have found a security issue within a ChainSafe project please notify us immediately. If an issue is confirmed, we will take all necessary precautions to ensure a statement and patch release is made in a timely manner.
Please email us a description of the flaw and any related information (e.g. reproduction steps, version) to security at chainsafe dot io.