How to Connect Fluent
Fluent Wallet
import { Conflux, Drip } from 'js-conflux-sdk';
const cfxClient = new Conflux();
// Actually,it is the window.conflux injected by Fluent Wallet. You can also access via window.conflux
cfxClient.provider = conflux;
conflux.on('chainChanged', cfxClient.updateNetworkId);
// Request accounts from fluent wallet, it will pop up a window to let user select account to connect with DApp when the DApp is first connected.
let accounts = await cfxClient.provider.request({ method: 'cfx_requestAccounts', params: [] });
// the you can use cfxClient to perform any operations that js-conflux-sdk supports.
let status = await cfxClient.getStatus();
console.log('chainId: ', status.chainId);
// the send transaction experience is same as js-conflux-sdk
let txHash = await cfxClient.cfx.sendTransaction({
from: accounts[0],
to: 'cfx:xxx',
value: Drip.fromCFX(1),
});
// this will pop up a window to let user confirm the transaction.Last updated
Was this helpful?