This section is for Chrome extension developers who want to add Blinks to third party sites like Twitter. If you're interested in Native blink support check out our React SDK or React Native SDK.
// contentScript.tsimport { setupTwitterObserver } from"@dialectlabs/blinks/ext/twitter";import { ActionConfig, ActionContext } from"@dialectlabs/blinks";// your RPC_URL is used to create a connection to confirm the transaction after action executionsetupTwitterObserver(newActionConfig(RPC_URL, {signTransaction:async (tx:string, context:ActionContext) => { ... },signMessage(data:string|SignMessageData, context:ActionContext) { ... },connect:async (context:ActionContext) => { ... }}))// orimport { type ActionAdapter } from"@dialectlabs/blinks";classMyActionAdapterimplementsActionAdapter {getmetadata() { ... }asyncsignTransaction(tx:string, context:ActionContext) { ... }asyncconnect(context:ActionContext) { ... }asyncconfirmTransaction(sig:string, context:ActionContext) { ... }asyncsignMessage(data:string|SignMessageData, context:ActionContext) { ... }}setupTwitterObserver(newMyActionAdapter());
Action Adapter & Multichain Compatibility
After implementation of sRFC 31, action developers can specify a target blockchain for an action by including metadata in responses. The action metadata is accessible within the ActionContext across ActionAdapter functions.
Chrome extension developers can also specify supported blockchains by defining them within the ActionAdapter. Additionally, other functions can be implemented to handle the action's blockchain based on the ActionContext.
For backward compatibility, the absence of blockchain IDs should be interpreted by Blink clients as actions targeting the Solana mainnet.