Filecoin
No Filecoin support
Chainstack deprecated support for Filecoin nodes. This page here is for legacy and in case you may find it useful.
MetaMask
You can set your MetaMask to interact through your Filecoin nodes..
-
Open your MetaMask and click the network selector.
-
In the network selector, click Custom RPC.
-
In the New RPC URL field, enter the node endpoint endpoint.
-
In the Chain ID field, enter the ID of the network:
- Calibration Testnet:
314159
- Calibration Testnet:
-
Click Save.
Truffle
Configure Truffle Suite to deploy contracts to your Filecoin nodes.
-
Install Truffle Suite, HD Wallet-enabled Web3 provider, and create a project.
-
Create a new environment in
truffle-config.js
, add your mnemonic phrase generated by a wallet and the Filecoin endpoint instead of FILECOINT_ENDPOINT:const HDWalletProvider = require("@truffle/hdwallet-provider"); const mnemonic = 'pattern enroll upgrade ...'; ... module.exports = { networks: { chainstack: { provider: () => new HDWalletProvider(mnemonic, "FILECOIN_ENDPOINT"), network_id: "*" }, } } };
Remix IDE
To make Remix IDE interact with the network through a Filecoin node:
- Get MetaMask and set it to interact through a Filecoin node. See Interacting through MetaMask.
- In Remix IDE, navigate to the Deploy tab. Select Injected Provider - MetaMask in Deploy & run transactions.
This will engage MetaMask and make Remix IDE interact with the network through a Filecoin node.
web3.js
Build DApps using web3.js and Filecoin nodes.
- Install web3.js.
- Connect over HTTP or WebSocket.
HTTP
Use the HttpProvider
object to connect to your node HTTPS endpoint and get the latest block number:
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('FILECOIN_ENDPOINT'));
web3.eth.getBlockNumber().then(console.log);
where FILECOIN_ENDPOINT is your node HTTPS endpoint.
WebSocket
Use the WebsocketProvider
object to connect to your node WSS endpoint and get the latest block number:
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.WebsocketProvider('FILECOIN_ENDPOINT'));
web3.eth.getBlockNumber().then(console.log);
where FILECOIN_ENDPOINT is your node WSS endpoint protected either with the key or password.
web3.py
Build DApps using web3.py and Filecoin nodes.
- Install web3.py.
- Connect over HTTP or WebSocket. See also EVM node connection: HTTP vs WebSocket.
HTTP
Use the HTTPProvider
to connect to your node endpoint and get the latest block number.
from web3 import Web3
web3 = Web3(Web3.HTTPProvider('FILECOIN_ENDPOINT'))
print(web3.eth.blockNumber)
from web3 import Web3
web3 = Web3(Web3.HTTPProvider('https://%s:%s@%s'% ("USERNAME", "PASSWORD", "HOSTNAME")))
print(web3.eth.blockNumber)
where
- FILECOIN_ENDPOINT — your node HTTPS endpoint
- HOSTNAME — your node HTTPS endpoint hostname
WebSocket
Use the WebsocketProvider
object to connect to your node WSS endpoint and get the latest block number.
from web3 import Web3
web3 = Web3(Web3.WebsocketProvider('FILECOIN_ENDPOINT'))
print(web3.eth.blockNumber)
from web3 import Web3
web3 = Web3(Web3.WebsocketProvider('wss://%s:%s@%s'% ("USERNAME", "PASSWORD", "HOSTNAME")))
print(web3.eth.blockNumber)
where
- FILECOIN_ENDPOINT — your node WSS endpoint
- HOSTNAME — your node WSS endpoint hostname
See also WebSocket connection to an EVM node.
ethers.js
Build DApps using ethers.js and Filecoin nodes.
- Install ethers.js.
- Connect over HTTP or WebSocket. See also EVM node connection: HTTP vs WebSocket.
HTTP
Use the JsonRpcProvider
object to connect to your node endpoint and get the latest block number:
const { ethers } = require("ethers");
var urlInfo = {
url: 'FILECOIN_ENDPOINT'
};
var provider = new ethers.providers.JsonRpcProvider(urlInfo, NETWORK_ID);
provider.getBlockNumber().then(console.log);
const { ethers } = require("ethers");
var urlInfo = {
url: 'YOUR_CHAINSTACK_ENDPOINT',
user: 'USERNAME',
password: 'PASSWORD'
};
var provider = new ethers.providers.JsonRpcProvider(urlInfo, NETWORK_ID);
provider.getBlockNumber().then(console.log);
where
- FILECOIN_ENDPOINT — your node HTTPS endpoint
- NETWORK_ID — Filecoin network ID:
- Calibration Testnet:
314159
- Calibration Testnet:
WebSocket
Use the WebSocketProvider
object to connect to your node WSS endpoint and get the latest block number:
const { ethers } = require("ethers");
const provider = new ethers.providers.WebSocketProvider('FILECOIN_ENDPOINT', NETWORK_ID);
provider.getBlockNumber().then(console.log);
where
- FILECOIN_ENDPOINT — your node WSS endpoint
- NETWORK_ID — Filecoin network ID:
- Calibration Testnet:
314159
- Calibration Testnet:
Updated 2 months ago