Using the Android phone made by the Solana Mobile project, am I able to use the phone's fingerprint or face scanner (like TouchID / FaceID on Apple's iOS) to confirm send payments of Solana using the keys of my phone's primary Solana wallet?
1 Answer
Yes it does for fingerprint but not face ID. The Solana Saga handles signing transactions using it's underlying secure enclave, which in turn allows verification using the finger print sensor out of the box. So doing the following (taken from the SMS docs) will automatically ask the user for a fingerprint if they have enabled this option on their Saga:
import { transact } from "@solana-mobile/mobile-wallet-adapter-protocol-web3js";
import { toByteArray } from "react-native-quick-base64";
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const signedTx = await transact(async (wallet) => {
// Authorize the wallet session
const authorizationResult = await wallet.authorize({
cluster: "devnet",
identity: APP_IDENTITY,
});
// Convert base64 address to web3.js PublicKey class
const authorizedPubkey = new PublicKey(
toByteArray(authorizationResult.accounts[0].address)
);
// Construct an instruction to transfer 1,000 lamports to a randomly generated account
const randomKeypair = Keypair.generate();
const instructions = [
SystemProgram.transfer({
fromPubkey: authorizedPubkey,
toPubkey: randomKeypair.publicKey,
lamports: 1_000,
}),
];
// Connect to an RPC endpoint and get the latest blockhash, to include in
// the transaction.
const latestBlockhash = await connection.getLatestBlockhash();
// Construct the Versioned message and transaction.
const txMessage = new TransactionMessage({
payerKey: fromPublicKey,
recentBlockhash: latestBlockhash.blockhash,
instructions,
}).compileToV0Message();
const versionedTransaction = new VersionedTransaction(txMessage);
// Request to sign the transaction
const signedTxs = await wallet.signTransactions({
transactions: [versionedTransaction],
});
return signedTxs[0];
});