
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
gen6-context
Advanced tools
React Context Provider for Polkadot/Substrate blockchain applications with connection management and account handling
A React Context Provider for Polkadot/Substrate blockchain applications with connection management and account handling.
npm install gen6-context
Make sure you have the following peer dependencies installed:
npm install react react-dom @polkadot/api @polkadot/extension-dapp @polkadot/ui-keyring @polkadot/util @polkadot/types
Note: The Polkadot dependencies are marked as peer dependencies to avoid version conflicts. Make sure your application uses compatible versions:
@polkadot/api: >=10.0.0@polkadot/extension-dapp: >=0.44.0@polkadot/ui-keyring: >=3.0.0@polkadot/util: >=12.0.0@polkadot/types: >=10.0.0Wrap your application with the Gen6ContextProvider:
import React from 'react'
import { Gen6ContextProvider } from 'gen6-context'
import App from './App'
function Root() {
return (
<Gen6ContextProvider>
<App />
</Gen6ContextProvider>
)
}
export default Root
Access the blockchain state and functions using the useGen6 hook:
import React from 'react'
import { useGen6 } from 'gen6-context'
function WalletConnect() {
const {
api,
apiState,
currentAccount,
keyring,
setCurrentAccount,
loadAccounts
} = useGen6()
const handleConnect = async () => {
await loadAccounts()
}
const handleAccountChange = (account) => {
setCurrentAccount(account)
}
if (apiState === 'CONNECTING') {
return <div>Connecting to blockchain...</div>
}
if (apiState === 'ERROR') {
return <div>Failed to connect to blockchain</div>
}
return (
<div>
<button onClick={handleConnect}>
Connect Wallet
</button>
{currentAccount && (
<div>Connected: {currentAccount.meta.name}</div>
)}
</div>
)
}
By default, Gen6 Context connects to the Gen6 network node at wss://gen6.app/node. You can override this by providing a custom WebSocket URL:
<Gen6ContextProvider socket="wss://your-custom-node.com">
<App />
</Gen6ContextProvider>
// This will connect to wss://gen6.app/node by default
<Gen6ContextProvider>
<App />
</Gen6ContextProvider>
// Connect to a different Polkadot/Substrate node
<Gen6ContextProvider socket="wss://rpc.polkadot.io">
<App />
</Gen6ContextProvider>
Returns an object with the following properties:
api: ApiPromise instance or nullapiState: Connection state ('CONNECTING' | 'READY' | 'ERROR' | null)apiError: Connection error if anykeyring: Keyring instance or nullkeyringState: Keyring loading state ('LOADING' | 'READY' | 'ERROR' | null)currentAccount: Currently selected account or nullcurrentIdentity: User identity informationhasConnectedBefore: Boolean indicating if user has connected beforesocket: WebSocket URL being usedsetCurrentAccount(account): Set the current active accountloadAccounts(): Load accounts from browser extensionssocket (optional): Custom WebSocket URL for the Polkadot nodechildren: React children componentsThe package includes comprehensive TypeScript definitions:
import type {
SubstrateState,
SubstrateAction,
SubstrateContextValue,
UseGen6Return
} from 'gen6-context'
@polkadot/api: Core Polkadot API@polkadot/extension-dapp: Browser extension integration@polkadot/ui-keyring: Account and keyring management@polkadot/util: Polkadot utilities@polkadot/types: Polkadot type definitionsMIT
FAQs
React Context Provider for Polkadot/Substrate blockchain applications with connection management and account handling
We found that gen6-context demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.