📝Sign Transaction

XRPL Snap is capable of signing and submitting transactions to XRP Ledger. When XRPL Snap gets request to sign transaction, user will be prompt to Accept or Reject signing of the transaction. Metadata of this transaction (Destination, amount,...) will also be visible in confirmation screen.

In order to sign transaction, payload needs to be sent to xrpl_sign RPC endpoint. Response of this call will be an object where one field will be signedTransaction. Value of this field can be passes as blob param to xrpl_submitRPC call.

Currently it is not possible to multisign transaction

After every sign request, user will be prompted to approve or reject the transaction like in the below image

Using XRPL SDK (draft)

Please note that XRPL SDK is not yet released. This is just an example of supposed solution.

<script src="./bundle.min.js"></script>
<script>
if (xrplClient) {
    // Replace with an actual transaction object
    const transaction = {
        "TransactionType": "Payment",
        "Destination": "rBvTkVQikhuZBoC7p3zdVbnPr1JscUsuA1",
        "Amount": "1000000"
    }; 
    const signedTransaction = xrplClient.sign(transaction);
    // Add any additional logic or handling
} else {
    console.log("Client not connected");
}
</script>

Native call

window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
      snapId: SNAP_ENDPOINT,
      request: {
          method: 'xrpl_sign',
          params: {
              data: {
                  "TransactionType": "Payment",
                  "Account": "rDtBYnfg4ehGdYKg98GbxPK63w2rWzYUpT",
                  "Destination": "rBvTkVQikhuZBoC7p3zdVbnPr1JscUsuA1",
                  "Amount": "1000000"
              }
          }
      }
  }
})

Last updated