Overview
Flow is an L1 blockchain featuring a distinctive multi-role architecture designed to increase throughput and efficiency without resorting to sharding. It adopts Cadence as its smart contract language and FCL (Flow Client Library) as the primary protocol for dapp, wallet, and user interactions with the chain.Magic Extension
This section will cover how to use our previous Flow integration via a custom extension that can be used alongside the core Magic SDK. You can use this extension to access Magic functionality alongside your FCL integration, however you do not need to use the authorization function shown here.Installation
Magic interacts with the Flow blockchain via Magic’s extension NPM package@magic-ext/flow
. The Flow extension also lets you interact with the blockchain using methods from Flow’s JavaScript SDK.
To get started, install the following dependencies for your project:
Initialization
The Magic class is the entry-point to the Magic SDK. It must be instantiated with a Magic publishable key.NOTEIf this is your first time using Magic with Flow, you may need to wait up to 30 seconds after logging in before your login completes because Magic has to wait for the Flow blockchain to confirm a transaction that creates your account.
JavaScript
Login
You can usemagic.flow.getAccount()
method to let users login.
JavaScript
Common Methods
Send Transaction
Getting Test Flow
Before you can send transaction on the Flow blockchain, you’ll need to acquire some test Flow (Flow’s native cryptocurrency for test network).- Go to our Flow Example application
- Login with your email address
- Copy your Flow public address
- Go to the Flow Faucet
- Fill in the form and paste your copied Flow public address in the Address field
- You can receive 1000 test Flow
- Now you can use your test Flow in our example app
Call Extension Method
Note that the Magic Flow extension follows the method names and conventions of Flow’s JavaScript SDK. You can use themagic.flow.authorization()
method to replace the fcl.authenticate()
.
JavaScript