Hokum Edge SDK
Hokum Edge SDK provide an easy way for developer to publish and subscribe with edge node and update the game state accordingly
Edge Node Client
Game State
Game State Handler is passed on EdgeNode client initialization. On every game state transition, this handler will be called with new and old game state along with a state transition type including pre-confirmation, reverted and external.
Game state is fetched from the state getter function that perform necessary operations to fetch the game state from the smart contract.
const edgeClient = new EdgeNode<GameState>({
bootnodes: PUBLIC_BOOTNODES,
stateGetter: async (oldState: GameState, transition: EdgeStateTransition, context?: any) {
...
},
stateHandler: async (newState: GameState, oldState: GameState, transition: EdgeStateTransition, context?: any) {
...
},
})Edge State Transition Types
There are three types of Edge State Transitions:
Pre-confirmation: The edge node and sequencer have acknowledged and simulated the transaction.
Reverted: The transaction has been reverted on the blockchain.
External: The game state changes due to manual refreshing.
Manually Refresh Game State
Developer can manually refresh game state based on certain effect from external factors. Manually refresh game state will have transition type = "external". Developer can pass an extra context which is forwarded to state getter and handler function
edgeClient.refreshState(context?);Transaction Management
The Hokum Edge Node SDK will offer an EIP-1193 compatible Ethereum Provider, which developers can integrate into any library of their choice, including but not limited to Wagmi, Viem, and ethers.js.
Additionally, the SDK will generate a client session key for signing transactions, and transaction requests will either be fetched from the nearest edge node or use locally cached data to simulate the transaction.
To access browser wallets such as Metamask and Rabby Wallet, it is necessary to initialize a separate typical provider or signer instance. This separation ensures enhanced security and performance in the Edge Node client.
Last updated