Magic
Magic is a developer SDK that you can integrate into your application to enable passwordless authentication using magic links - similar to Slack and Medium.
When users want to sign up or log in to your application:
- User requests a magic link sent to their email address
- User clicks on that magic link
- User is securely logged into the application
If it's a web application, users are logged into the original tab, even if the user clicked on the magic link on a different browser or mobile device!
note
You can skip straight to our reference example:
Installation
Magic interacts with the Zilliqa blockchain via Magic's extension NPM package @magic-ext/zilliqa. The Zilliqa extension also lets you interact with the blockchain using methods from Zilliqa's Javascript SDK.
- npm
- yarn
Initializing Extension
To initialize the magic extension, you would need to specify the Zilliqa RPC Node URL which can be found here. You would need to specify your API Key for Magic, which you'll get by signing up on Magic's dashboard - if you face any issues, refer to Magic's documentation.
- js
Get User Wallet
Get Wallet
Using getWallet function to get a Zilliqa wallet for the current user.
- js
Send Transaction
Getting Test ZIL
Before you can send transaction on the Zilliqa blockchain, you'll need to acquire some test ZIL (Zilliqa's native cryptocurrency for test network).
- Go to our Magic Example application
- Login with your email address
- Copy your Zilliqa public address
- Go to the ZIL Faucet
- Paste your copied Zilliqa public address in the text input
- You can receive 300 test ZIL
- Now you can use your test ZIL in our example app
Call Extension Method
To send a standard Zilliqa blockchain transaction, you can call the magic.zil.sendTransaction method.
- js
Deploy Smart Contract
Getting Test ZIL
Before you can send transaction on the Zilliqa blockchain, you'll need to acquire some test ZIL (Zilliqa's native cryptocurrency for test network).
- Go to our Magic Example application
- Login with your email address
- Copy your Zilliqa public address
- Go to the ZIL Faucet
- Paste your copied Zilliqa public address in the text input
- You can receive 300 test ZIL
- Now you can use your test ZIL in our example app
Call Extension Method
To deploy a smart contract, you can call the magic.zilliqa.deployContract method.
- js