Home

Sign & Send Transactions with Embedded Signer

Signing and Send a TransactionIntent#

The steps to sign a transaction with an embedded signer are as follows:

  1. First, create a request to your backend to create a transactionIntent.
  2. Then, the backend will return a transactionIntent with a nextAction.
  3. Finally, use the nextAction to sign the transaction with the embedded signer.

The transaction will be automatically signed and broadcasted by using the sendSignatureTransactionIntentRequest method.


_29
const handleCollectButtonClick = async () => {
_29
try {
_29
setCollectLoading(true);
_29
const collectResponse = await fetch(`/api/examples/protected-collect`, {
_29
method: "POST",
_29
headers: {
_29
"Content-Type": "application/json",
_29
},
_29
});
_29
const collectResponseJSON = await collectResponse.json();
_29
_29
if (collectResponseJSON.data?.nextAction) {
_29
console.log("config", config);
_29
_29
const response = await openfort.sendSignatureTransactionIntentRequest(
_29
collectResponseJSON.data.id,
_29
collectResponseJSON.data.nextAction.payload.userOperationHash
_29
);
_29
console.log("response", response);
_29
}
_29
_29
console.log("success:", collectResponseJSON.data);
_29
alert("Action performed successfully");
_29
} catch (error) {
_29
console.error("Error:", error);
_29
} finally {
_29
setCollectLoading(false);
_29
}
_29
};

Examples#