Send Transaction

signAndSendTransaction()

If you are logged in to Face Wallet, users can send transactions. When sending a transaction, users would review the transaction information and enter the PIN code through Face Wallet modal.

import { Face, Network } from '@haechi-labs/face-sdk';
import { LAMPORTS_PER_SOL, PublicKey, SystemProgram, Transaction } from "@solana/web3.js";

const face = new Face({
  network: Network.SOLANA, 
  apiKey: 'YOUR_DAPP_API_KEY'
});
const faceProvider = face.solana.getProvider();

// Dapp should choose the input required to send transaction
const signerKey = faceProvider.getPublicKey();
const receiverAddress = 'EQo5KUyAuxdDnTx1aC247inHVuvZXk6MSkrqKkWVKXPH'; 
const amount = 0.1 * LAMPORTS_PER_SOL;

// Build a transaction with web3.js
const transaction = new Transaction().add(
	SystemProgram.transfer({
  	fromPubkey: new PublicKey(signerKey),
    toPubkey: new PublicKey(receiverAddress),
    lamports: amount,
   )}
);

const transactionSignature = await faceProvider.signAndSendTransaction(transaction);

When the transaction is sent, the Face Wallet modal switches to the [Processing] status screen. Even if the user closes the [Processing] screen, the transaction would be executed when it is mined because it has already delivered to the blockchain network. If the transaction is mined before the user closes the [Processing] screen, the Face Wallet modal switches to the [Success] status screen.