@vela-ventures/ao-sync-sdk
is a JavaScript/TypeScript SDK for connecting your application to the Beacon Wallet. This library provides an easy way to interact with Beacon Wallet for Arweave and AO-based applications while delegating signing, encryption, and logic to the wallet itself.
- Seamless Wallet Connection: Connect to the Beacon Wallet via MQTT.
- QR Code Authentication: Generate QR codes for easy wallet scanning.
- Reconnect Support: Automatically reconnect to the wallet using stored session data.
Install the SDK via npm:
npm install @vela-ventures/ao-sync-sdk
import WalletClient from "@vela-ventures/ao-sync-sdk";
const walletClient = new WalletClient();
To establish a connection with Beacon Wallet, use the connect
method:
await walletClient.connect({
permissions: [
"ACCESS_ADDRESS",
"ACCESS_PUBLIC_KEY",
"SIGN_TRANSACTION"
],
appInfo: {
name: "MyApp",
logo: "https://myapp.com/logo.png"
},
gateway: {
host: "arweave.net",
port: 443,
protocol: "https"
},
brokerUrl: "wss://aosync-broker-eu.beaconwallet.dev:8081",
options: {
protocolVersion: 5
}
});
This will generate a QR code that the user can scan with their Beacon Wallet to establish a connection.
The SDK uses an event-driven architecture. You can listen for connection, disconnection, or custom events:
walletClient.on("connected", (data) => {
console.log("Wallet connected:", data);
});
walletClient.on("disconnected", (data) => {
console.log("Wallet disconnected:", data);
});
Once connected, you can use the wallet to sign transactions or data:
const signedTx = await walletClient.signTransaction(transactionData);
console.log("Signed Transaction:", signedTx);
const signedData = await walletClient.signDataItem(dataItem);
console.log("Signed Data Item:", signedData);
To disconnect the wallet:
await walletClient.disconnect();
new WalletClient(responseTimeoutMs = 30000, txTimeoutMs = 300000)
-
responseTimeoutMs
(optional): Timeout duration for responses (default: 30 seconds). -
txTimeoutMs
(optional): Timeout duration for transactions (default: 5 minutes).
Establish a connection with the Beacon Wallet.
Reconnect to the wallet using session data from sessionStorage
.
Sign an Arweave transaction.
-
transaction
: The transaction object to sign.
Sign a data item.
-
dataItem
: The data item to sign.
Disconnect from the Beacon Wallet.
-
connected
: Fired when the wallet is successfully connected. -
disconnected
: Fired when the wallet is disconnected.
-
mqtt
: MQTT protocol client. -
qrcode
: QR code generation. -
uuid
: Universally unique identifiers. -
arweave/web
: Arweave SDK for transactions and data handling.
Feel free to open issues or submit pull requests to enhance this SDK. Contributions are welcome!