diff --git a/docs/reference/freighter.mdx b/docs/reference/freighter.mdx index ae3c5bb6..ef5fbfcf 100644 --- a/docs/reference/freighter.mdx +++ b/docs/reference/freighter.mdx @@ -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. \ No newline at end of file