Use This When
- you want the recommended React integration path
- you need to understand the smallest public wallet contract a dApp uses
- you want to connect a dApp, inspect the wallet signing contract, sign a transaction, and then submit it with
@thru/thru-sdk
Choose The Right Package Layer
| Package | Use it when | Avoid it when |
|---|---|---|
@thru/react-sdk | Your app already uses React and you want provider plus hooks. | You are not using React. |
@thru/browser-sdk | You want a simple browser-side SDK without React. | You need raw iframe lifecycle control. |
@thru/embedded-provider | You are building a custom host around the iframe and postMessage layer. | You just need normal dApp integration. |
Install
For the recommended React path:Minimal React Setup
Wrap the app withThruProvider and point it at the hosted wallet iframe.
Minimal Connect Flow
connect() is the dApp entrypoint. The wallet resolves the request against the iframe, origin, and app metadata.
Minimal Sign-And-Submit Flow
UsegetSigningContext() before you build the transaction. The selected wallet account is the managed account the user sees, but the actual fee payer and signer can be the embedded manager profile.
signTransaction() accepts either:
- signing payload bytes from
transaction.toWireForSigning() - raw transaction bytes from
transaction.toWire()
Signing Context
Callwallet.getSigningContext() before building transactions that need exact signer or fee-payer information.
The current embedded wallet contract returns a managed-fee-payer shape:
- which managed account the user thinks they are acting as
- which public key actually signs and pays for network submission
What The dApp Owns
The dApp is responsible for:- deciding when to call
connect() - calling
getSigningContext()before building transactions that depend on signer or fee-payer identity - building the unsigned transaction bytes with the correct fee payer
- calling
signTransaction()with a base64 payload - submitting the returned raw transaction bytes directly
- showing the right status while the wallet UI is open
- presenting connection and approval UI
- unlocking with passkey if required
- selecting the current wallet account
- returning the current signing contract for the embedded environment
- returning canonical raw transaction bytes after signing
Important Assumptions
- the iframe URL must be a trusted wallet origin:
https://wallet.thru.orgor localhost during development signTransaction()expects a non-empty base64 payload in one of the accepted encodingsgetSigningContext().feePayerPublicKeyis the source of truth for the network fee payer- the wallet contract is intentionally narrow: connect, disconnect, account selection, and transaction signing
Open Next
- Approval and Signing to understand what happens after a dApp calls
connect()orsignTransaction() - Troubleshooting if the request flow stalls or the transaction never appears on-chain