Client Reference
The base package that provides access to the Dynamic Client, which can be extended with extension packages.
Functions
DynamicSDK.init
DynamicSDK init({
required ClientProps props,
})
Initiates a singleton of a client object, which provides an interface to read state, trigger actions and listen to events of our SDK.
Objects
ClientProps
The parameters that are acceptable by the DynamicSDK.init method.
Param | Type | Description |
---|---|---|
environmentId | string | The ID of the environment of your dynamic application. |
apiBaseUrl | string? | Allows you to override the URL to which the SDK will make its API requests. |
cssOverrides | string? | Allows you to inject CSS into our UI modules (currently out of effect) |
appName | string? | How you’d like your app to be named in our copies. |
appLogoUrl | string? | A URL of the logo of your app. |
logLevel | LoggerLevel? | Allows you to set the level of the logs to the console |
DynamicSDK.instance
The base object of a client.
Since clients can be extended (and thus have their objects composed with those of the extensions), this is considered the most basic kind of client: the one that is returned from the DynamicSDK.init method.
It is composed of properties which we call modules. Note that all modules have state properties and implement one or more streams.
For every property that is a state, there will always be a stream named with
the same name plus "Changes"
, which will be triggered when the property
changes value. We will omit these from the docs below as they are implicit.
auth
module
Provides access to authentication related properties and methods of the SDK.
Property | Type | Description |
---|---|---|
token | string | null | The JWT of the currently logged in user. |
authenticatedUser | UserProfile | null | The UserProfile object of the logged in user. |
logout | Future<void> logout() | Allows you to log the current user out. |
auth.email
submodule
Provides methods to send, re-send and verify OTPs to email.
Property | Type | Description |
---|---|---|
sendOTP | Future<void> sendOTP(String email) | Sends an OTP token to the target email. |
resendOTP | Future<void> resendOTP() | Sends another OTP token to the same email as the last call to sendOTP . |
verifyOTP | Future<void> verifyOTP(String token) | Receives an OTP token and logs the user in if it is valid. |
auth.sms
submodule
Provides methods to send, re-send and verify OTPs to phone numbers.
Property | Type | Description |
---|---|---|
sendOTP | Future<void> sendOTP(PhoneData phoneData) | Sends an OTP token to the target PhoneData. |
resendOTP | Future<void> resendOTP() | Sends another OTP token to the same phone number as the last call to sendOTP . |
verifyOTP | Future<void> verifyOTP(String token) | Receives an OTP token and logs the user in if it is valid. |
auth.social
submodule
Provides a method to connect social accounts.
Property | Type | Description |
---|---|---|
connect | Future<void> connect({required SocialProvider provider, String? redirectPathname}) | Requests social connection to the provided SocialProvider. |
sdk
module
Gives insight over the state of the SDK.
Property | Type | Description |
---|---|---|
loaded | boolean | Whether the SDK has loaded and is ready to handle requests. |
ui
module
Provides access to Dynamic’s UI.
Property | Type | Description |
---|---|---|
showAuth | void | Opens up Dynamic’s authentication flow modal for your user to sign in. Automatically closes when finished. |
showUserProfile | void | Opens up Dynamic’s user profile modal, allowing your user to manage their profile and wallets. |
wallets
module
Provides access to the user’s wallets.
Property | Type | Description |
---|---|---|
userWallets | BaseWallet[] | The array of all the user’s wallets. |
primary | BaseWallet | null | The primary wallet of the user. |
setPrimary | Future<void> setPrimary({required String walletId}) | Sets primary [wallet]/sdks(/react-sdk/objects/wallet) of the user. |
getBalance | Future<String> getBalance({required BaseWallet wallet}) | Returns the balance of a wallet. |
getNetwork | Future<Network> getNetwork({required BaseWallet wallet}) | Returns the network the wallet is connected to. |
signMessage | Future<String> signMessage({required BaseWallet wallet, required String message}) | Signs a message with this wallet. |
switchNetwork | Future<void> switchNetwork({required BaseWallet wallet, required Network network}) | Switches the wallet’s network. |
wallets.embedded
submodule
Allows interacting with and creating an embedded wallet for the current user.
Property | Type | Description |
---|---|---|
hasWallet | boolean | Whether the logged in user has an embedded wallet. |
getWallet | BaseWallet | null | Retrieves the embedded wallet of the current user, or null if it doesn’t exist. |
createWallet | BaseWallet | Creates an embedded wallet for the current user. Throws if one already exists. |
Was this page helpful?