JSPM

  • Created
  • Published
  • Downloads 1497
  • Score
    100M100P100Q10735F
  • License MIT

Magic SDK Connect Extension for Web environments.

Package Exports

  • @magic-ext/connect

Readme

๐Ÿ”’ Magic Connect Extension for Web Browsers and React Native Apps

<MagicLabs>

Magic Connect JavaScript SDK extension.

License ยท Changelog ยท Contributing Guide

๐Ÿ“– Documentation

See the developer documentation to learn how to get started with Connect in Magic SDK.

๐Ÿ”— Installation

Integrating your app with Magic will require our client-side NPM package and the Connect extension:

# Via NPM:
npm install --save magic-sdk @magic-ext/connect # If you're targeting web browsers
npm install --save @magic-sdk/react-native-bare @magic-ext/connect # If you're targeting Bare React Native
npm install --save @magic-sdk/react-native-expo @magic-ext/connect # If you're targeting Expo React Native

# Via Yarn:
yarn add magic-sdk @magic-ext/connect # If you're targeting web browsers
yarn add @magic-sdk/react-native-bare @magic-ext/connect # If you're targeting Bare React Native
yarn add @magic-sdk/react-native-expo @magic-ext/connect # If you're targeting Expo React Native

Alternatively, you can load via CDN with by adding a script tag to your appโ€™s <head>:

<script src="https://cdn.jsdelivr.net/npm/magic-sdk/dist/magic.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@magic-ext/connect/dist/extension.js"></script>

โšก๏ธ Quick Start

Sign up or log in to the developer dashboard to receive API keys that will allow your application to interact with Magic's APIs.

From your login page:

import Web3 from 'web3';
import { Magic } from 'magic-sdk'; // web browsers
import { Magic } from '@magic-sdk/react-native-bare'; // Bare React Native
import { Magic } from '@magic-sdk/react-native-expo'; // Expo React Native
import { ConnectExtension } from '@magic-ext/connect';

const magic = new Magic('YOUR_API_KEY', {
  extensions: [new ConnectExtension()],
  network: 'mainnet' // 'mainnet' or 'testnet'
});

const web3 = new Web3(magic.rpcProvider);

await web3.eth.getAccounts();