API Reference
Constructor
const wallet = new SaturnWallet();
Creates a new instance of the Saturn Wallet SDK. Automatically checks for existing connections and validates them.
Methods
getCurrentAddress()
getCurrentAddress()
Returns the currently connected wallet address with validation.
try {
const address = await wallet.getCurrentAddress();
console.log(`Current address: ${address}`);
} catch (error) {
console.error("Error getting address:", error.message);
}
Returns: Promise<string>
- The wallet address
Throws: Error if wallet not connected or validation fails
connect(message)
connect(message)
Connects to the wallet by requesting a message signature with ownership proof.
try {
const connection = await wallet.connect("Sign this message to connect");
// Returns: { address: string, signature: string, publicKey: string }
} catch (error) {
console.error("Connection error:", error.message);
}
Parameters:
message
(string, required): Message to be signed for connection
Returns: Promise<Object>
- Connection object with address, signature, and publicKey
Promise<Object>
- Connection object with address, signature, and publicKeyThrows: Error if connection fails, message is invalid, or validation fails
sendTransaction(params)
sendTransaction(params)
Sends a transaction with the specified parameters and comprehensive validation.
try {
const txResult = await wallet.sendTransaction({
asset: "CIRX", // Asset symbol (required)
amount: "1.5", // Amount to send (required)
toAddress: "0x...", // Recipient address (required)
});
// Returns: { hash: string, block: string, status: string }
} catch (error) {
console.error("Transaction error:", error.message);
}
Parameters:
params
(object, required): Transaction parametersasset
(string): Asset symbol (e.g., "CIRX")amount
(string): Amount to send (must be positive number)toAddress
(string): Recipient address
Returns: Promise<Object>
- Transaction result with hash, block, and status
Throws: Error if wallet not connected, invalid parameters, or transaction fails
disconnect()
disconnect()
Disconnects the wallet from the current dApp and clears local state.
try {
const success = await wallet.disconnect();
console.log(`Disconnected: ${success}`);
} catch (error) {
console.error("Disconnect error:", error.message);
// Note: Local state is cleared even if disconnect call fails
}
Returns: Promise<boolean>
- True if disconnected successfully
Throws: Error if disconnect operation fails (local state still cleared)
isConnected()
isConnected()
Checks if the wallet is currently connected with full validation.
try {
const connected = wallet.isConnected();
console.log(`Connected: ${connected}`);
} catch (error) {
console.error("Validation error:", error.message);
// Connection state has been cleared due to validation failure
}
Returns: boolean
- True if wallet is connected and validated
Throws: Error if connection validation fails (clears invalid connection state)
Last updated