Hedera

Hedera

#Overview

Hedera is an EVM-compatible decentralized, open-source and proof-of-stake Layer1 blockchain. It utilizes the leaderless, asynchronous Byzantine Fault Tolerance (aBFT) hashgraph, offering fast transactions and low fees.

As Hedera is EVM compatible, you can follow the Ethereum documentation to send your first transaction and utilize all other wallet features.

#Installation

Magic interacts with the Hedera blockchain via Magic's extension NPM package @magic-ext/hedera. The Hedera extension also lets you interact with the blockchain using methods from Hedera SDK.

NPM
Yarn
01npm install --save @magic-ext/hedera

#Configure Hedera

ES Modules/TypeScript

Typescript
01import { Magic } from 'magic-sdk';
02import { HederaExtension } from '@magic-ext/hedera';
03
04const magic = new Magic("YOUR_API_KEY", {
05    extensions: [new HederaExtension({
06        network: 'testnet' // 'mainnet' or 'testnet'
07    })]
08});

#Send Transaction

#Call Extension Method

Note that the Magic Hedera extension follows the method names and conventions by hedera-sdk-js. To send a standard Hedera blockchain transaction, you can call the inject the MagicWallet to hedera-sdk-js. More details please reference to example-hedera github repo.

ES Modules/TypeScript

Typescript
01import { Magic } from 'magic-sdk';
02import { HederaExtension } from '@magic-ext/hedera';
03
04const magic = new Magic("YOUR_API_KEY", {
05    extensions: [new HederaExtension({
06        network: 'testnet' // 'mainnet' or 'testnet'
07    })]
08});
09
10const { publicKeyDer } = await magic.hedera.getPublicKey()
11
12const magicSign = message => magic.hedera.sign(message);
13const magicWallet = new MagicWallet(publicAddress, new MagicProvider('testnet'),                publicKeyDer, magicSign)
14
15let transaction = await new TransferTransaction()
16       .setNodeAccountIds([new AccountId(3)])
17       .addHbarTransfer(publicAddress, -1 * sendAmount)
18       .addHbarTransfer(destinationAddress, sendAmount)
19       .freezeWithSigner(magicWallet);
20
21
22
23transaction = await transaction.signWithSigner(magicWallet);
24const result = await transaction.executeWithSigner(magicWallet);
25const receipt = await result.getReceiptWithSigner(magicWallet);
26
27console.log(receipt.status.toString());

#Compatibility

*Some features are not yet compatible such as the Widget UI.

Need a feature or see a problem? File an issue on our github repo.

#Resources & Tools