Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
adds docs for Freighters signAuthEntry API
Browse files Browse the repository at this point in the history
  • Loading branch information
aristidesstaffieri committed Sep 27, 2023
1 parent f5939a2 commit 3e0e682
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/reference/freighter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ If you're building a JS dapp, easily sign Soroban transactions using the [Freigh
2. Now, you can use the `signTransaction` [method](https://docs.freighter.app/docs/guide/usingFreighterNode) from `@stellar/freighter-api` in your dapp to sign Soroban XDRs using the account in Freighter.

3. Upon calling `signTransaction`, Freighter will open and prompt the user to sign the transaction. Approving the transaction will return the signed XDR to the requesting dapp.

## Sign Authorization Entries

In order to take advantage of [contract authorization](https://soroban.stellar.org/docs/fundamentals-and-concepts/authorization), you can use Freighters API to sign an authorization entry.
A good example of how signing an authorization entry works can be found in the [`authorizeEntry` helper of
soroban-client](https://github.com/stellar/js-stellar-base/blob/e3d6fc3351e7d242b374c7c6057668366364a279/src/auth.js#L97).

Like in the helper, you can construct a [`HashIdPreimageSorobanAuthorization`](https://github.com/stellar/js-stellar-base/blob/a9567e5843760bfb6a8b786592046aee4c9d38b2/types/next.d.ts#L6895) and use the xdr representation of that structure to call `await freighterApi.signAuthEntry(preimageXdr)`.
This call will return a Buffer of the signed hash of the `HashIdPreimageSorobanAuthorization` passed in, which can then be used to submit to the network during a contract authorization workflow.

For a full example of how to use contract authorization, [the scaffold-soroban demo for an atomic swap](https://github.com/stellar/soroban-react-atomic-swap) makes use of both contract auth and Freighter's `signAuthEntry` API.

0 comments on commit 3e0e682

Please sign in to comment.