@moveindustries/mini-app-sdk
v0.6.1
Published
Official SDK for building Movement Mini Apps
Downloads
108
Readme
@moveindustries/mini-app-sdk
Official SDK for building Movement Mini Apps - blockchain-powered applications that run inside the Movement Everything mobile app.
Installation
npm install @moveindustries/mini-app-sdkQuick Start
Vanilla JavaScript
import { getMovementSDK } from '@moveindustries/mini-app-sdk';
const sdk = getMovementSDK();
if (sdk) {
// Connect wallet
const account = await sdk.connect();
console.log('Connected:', account.address);
// Send transaction
const result = await sdk.sendTransaction({
function: '0x1::coin::transfer',
arguments: [recipientAddress, amount],
type_arguments: ['0x1::aptos_coin::AptosCoin']
});
console.log('Transaction hash:', result.hash);
}React / Next.js
import { useMovementSDK } from '@moveindustries/mini-app-sdk';
function MyApp() {
const { sdk, isConnected, address, connect, sendTransaction } = useMovementSDK();
return (
<div>
{!isConnected ? (
<button onClick={connect}>Connect Wallet</button>
) : (
<div>
<p>Connected: {address}</p>
<button onClick={() => sendTransaction({
function: '0x1::coin::transfer',
arguments: [recipient, '100'],
type_arguments: ['0x1::aptos_coin::AptosCoin']
})}>
Send Tokens
</button>
</div>
)}
</div>
);
}API Reference
Functions
getMovementSDK()
Get the Movement SDK instance if available.
const sdk = getMovementSDK();isInMovementApp()
Check if running inside Movement app.
if (isInMovementApp()) {
// SDK is available
}waitForSDK(timeout?)
Wait for SDK to load (useful for iframes).
const sdk = await waitForSDK(5000); // 5 second timeoutReact Hooks
useMovementSDK()
React hook for SDK access.
const {
sdk, // SDK instance
isConnected, // Connection status
address, // Wallet address
isLoading, // Loading state
error, // Error state
connect, // Connect function
sendTransaction // Send transaction function
} = useMovementSDK();useMovementAccount()
React hook for account info.
const {
account, // Account object { address, publicKey }
isConnected, // Connection status
isLoading, // Loading state
error // Error state
} = useMovementAccount();SDK Methods
connect()
Connect to user's wallet.
const account = await sdk.connect();
// { address: string, publicKey: string }getAccount()
Get current account info.
const account = await sdk.getAccount();sendTransaction(payload)
Sign and submit a transaction.
const result = await sdk.sendTransaction({
function: '0x1::coin::transfer',
arguments: [recipient, amount],
type_arguments: ['0x1::aptos_coin::AptosCoin']
});
// { hash: string, success: boolean }signMessage(payload)
Sign a message.
const result = await sdk.signMessage({
message: 'Hello Movement!',
nonce: '12345'
});
// { signature: string, publicKey: string }haptic(options) (Optional)
Trigger haptic feedback.
await sdk.haptic?.({
type: 'impact',
style: 'medium'
});notify(options) (Optional)
Show notification.
await sdk.notify?.({
title: 'Success!',
body: 'Transaction complete'
});openUrl(url, target?) (Optional)
Open URL externally or in-app.
sdk.openUrl?.('https://example.com', 'external');close() (Optional)
Close the mini app.
sdk.close?.();TypeScript Support
Full TypeScript support with comprehensive type definitions included.
Using Type Definitions
For direct window.movementSDK usage (without npm package), reference the type definitions:
/// <reference path="./movement-sdk.d.ts" />
// Now you have full IntelliSense and type checking!
const result = await window.movementSDK.sendTransaction({
function: '0x1::aptos_account::transfer',
arguments: ['0x123...', '1000000'],
title: 'Send MOVE',
useFeePayer: true,
gasLimit: 'Sponsored'
});Import Types
import type {
MovementSDK,
SendTransactionParams,
TransactionResult,
UserInfo,
PopupOptions
} from '@moveindustries/mini-app-sdk';Transaction Parameters
The SendTransactionParams interface provides full type safety:
interface SendTransactionParams {
/** Move function: address::module::function_name */
function: string;
/** Type arguments (optional) */
type_arguments?: string[];
/** Function arguments (optional) */
arguments?: any[];
/** UI title (optional) */
title?: string;
/** UI description (optional) */
description?: string;
/** Use sponsored transactions (optional) */
useFeePayer?: boolean;
/** Gas limit (optional) - use 'Sponsored' for sponsored txs */
gasLimit?: number | 'Sponsored';
}Note: The to field is now optional and automatically extracted from the function field (the address before the first ::).
Examples
Check out example projects:
Documentation
Full documentation: https://docs.movementnetwork.xyz/
License
Apache 2.0
