arkconnect
v1.0.0
Published
JavaScript SDK for interacting with wallet extensions through a common interface
Maintainers
Readme
ArkConnect
A JavaScript SDK for interacting with wallet extensions through a common interface.
Installation
npm install arkconnectUsage
import ArkConnect from 'arkconnect';
// Initialize ArkConnect
const arkConnect = new ArkConnect({
debug: true, // Enable debug logging
timeout: 30000, // Request timeout in ms
extensionName: 'ark-wallet' // Custom extension name
});
// Connect to wallet
await arkConnect.connect();
// Get all available signers
const signers = await arkConnect.getSigners();
console.log('Available signers:', signers);
// Get default signer
const signer = await arkConnect.getSigner();
console.log('Default signer:', signer);
// Get public key (npub)
const npub = await arkConnect.getNpub();
console.log('Public key:', npub);
// Get VUTXOs
const vutxos = await arkConnect.getVUTXOs();
console.log('VUTXOs:', vutxos);
// Sign a message
const message = 'Hello, Ark!';
const signature = await arkConnect.signMessage(message);
console.log('Message signature:', signature);API Reference
Constructor
new ArkConnect(options)Options:
debug(boolean, default:false): Enable debug loggingtimeout(number, default:30000): Request timeout in millisecondsextensionName(string, default:'ark-wallet'): Name of the wallet extension
Methods
connect(): Promise<boolean>
Connect to the wallet extension.
disconnect(): Promise<boolean>
Disconnect from the wallet extension.
isExtensionAvailable(): boolean
Check if the wallet extension is available in the browser.
getSigners(): Promise<Signer[]>
Get all available signers from the wallet extension.
getSigner(): Promise<Signer>
Get the default signer from the wallet extension.
getNpub(): Promise<string>
Get the public key (npub) of the current signer.
getVUTXOs(): Promise<VUTXO[]>
Get Virtual UTXOs for the current signer.
signMessage(message: string): Promise<string>
Sign a message with the current signer.
Types
interface Signer {
id: string;
name: string;
address?: string;
publicKey?: string;
[key: string]: any;
}
interface VUTXO {
id: string;
value: number;
script?: string;
address?: string;
height?: number;
coinbase?: boolean;
[key: string]: any;
}Browser Support
ArkConnect supports all modern browsers:
- Chrome >= 67
- Firefox >= 68
- Safari >= 14
- Edge >= 79
License
MIT
