react-native-trust-sdk
The react-native-trust-sdk lets you sign Ethereum transactions and messages with Trust Wallet so that you can bulid a react native DApp without having to worry about keys or wallets.
Installation
npm i react-native-trust-sdk
Configuring Android
Make sure you have set up intent-filter for your app (documentation here)
example app settings:
Configuring iOS
Make sure you have set up url scheme for your app (Open Xcode an click on your project. Go to the 'Info' tab and expand the 'URL Types' group).
example app settings:
CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLSchemes trust-rn-example
// iOS 9.x or newer - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options // If your app is using Universal Links - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
Example
Checkout the example typescript project in example
folder.
npm install && npm startreact-native run-ios
Usage
import the package:
;
initialize an instance, e.g. in componentDidMount
:
;
sign a message:
;wallet.signMessagepayload .then.catch;
sign a transaction:
;wallet.signTransactionpayload .then .catch;});
clean up all resolve handlers, e.g. incomponentWillUnmount
:
wallet.cleanup;
Contributing
You are welcome! Create pull requests and help to improve the package.
License
GPLv3