
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@metamask/sdk-react-native
Advanced tools
MetaMask SDK for React Native applications, enabling seamless integration with MetaMask for blockchain interactions.
The MetaMask SDK React Native allows developers to integrate MetaMask seamlessly into React Native applications.
Install the SDK:
yarn add @metamask/sdk-react-native
AppDelegate.m
:#import <React/RCTBundleURLProvider.h>
#import <React/RCTBridge.h>
#import <React/RCTLinkingManager.h>
AppDelegate.m
to handle deep links:- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:app openURL:url options:options];
}
Add the URL scheme to your Xcode project:
Info
tab.URL Types
, click the +
button to add a new URL type.URL Schemes
field, add your custom scheme (e.g., yourappscheme
).Install CocoaPods dependencies:
cd ios && pod install
import React from 'react';
import { AppRegistry } from 'react-native';
import App from './App';
import { MetaMaskProvider } from '@metamask/sdk-react-native';
const sdkOptions = {
dappMetadata: {
name: 'Demo React Native App',
url: 'https://yourdapp.com',
iconUrl: 'https://yourdapp.com/icon.png',
scheme: 'yourappscheme',
},
infuraAPIKey: 'YOUR_INFURA_API_KEY', // Optional, but highly recommended for a better user experience
};
const Root = () => (
<MetaMaskProvider sdkOptions={sdkOptions}>
<App />
</MetaMaskProvider>
);
AppRegistry.registerComponent('YourAppName', () => Root);
import { useSDK } from '@metamask/sdk-react-native';
import React from 'react';
import { View, Button, Text } from 'react-native';
const App = () => {
const { sdk, connected, connecting, provider, chainId, account } = useSDK();
const connect = async () => {
try {
await sdk?.connect();
} catch (err) {
console.warn('Failed to connect..', err);
}
};
return (
<View style={{ padding: 20 }}>
<Button title="Connect" onPress={connect} disabled={connecting} />
{connected && (
<View>
{chainId && <Text>Connected chain: {chainId}</Text>}
{account && <Text>Connected account: {account}</Text>}
</View>
)}
</View>
);
};
export default App;
Option | Type | Description | Mandatory |
---|---|---|---|
dappMetadata.name | string | Name of your dApp | Yes |
dappMetadata.url | string | URL of your dApp | Yes |
dappMetadata.iconUrl | string | URL of the icon of your dApp | No |
dappMetadata.scheme | string | Custom scheme for your React Native app | Yes |
infuraAPIKey | string | Your Infura API key | No |
connect()
: Connect to MetaMask.connectAndSign({ msg })
: Connect to MetaMask and sign a message.connectWith(req)
: Connect to MetaMask with a specific request.terminate()
: Terminate the MetaMask connection.request(req)
: Make a request to MetaMask.batchRequest(requests)
: Make batch requests to MetaMask.getChainId()
: Get the current chain ID.getSelectedAddress()
: Get the selected address.Refer to the example folder for more info on how to use the SDK.
For additional support, open an issue on our GitHub repository.
FAQs
MetaMask SDK for React Native applications, enabling seamless integration with MetaMask for blockchain interactions.
The npm package @metamask/sdk-react-native receives a total of 20 weekly downloads. As such, @metamask/sdk-react-native popularity was classified as not popular.
We found that @metamask/sdk-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.