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 Ethereumdocumentation 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 install --save @magic-ext/hedera

Configure Hedera

JavaScript
import { Magic } from 'magic-sdk';
import { HederaExtension } from '@magic-ext/hedera';

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

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.
JavaScript
import { Magic } from 'magic-sdk';
import { HederaExtension } from '@magic-ext/hedera';

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

const { publicKeyDer } = await magic.hedera.getPublicKey()

const magicSign = message => magic.hedera.sign(message);
const magicWallet = new MagicWallet(publicAddress, new MagicProvider('testnet'), publicKeyDer, magicSign);

let transaction = await new TransferTransaction()
  .setNodeAccountIds([new AccountId(3)])
  .addHbarTransfer(publicAddress, -1 * sendAmount)
  .addHbarTransfer(destinationAddress, sendAmount)
  .freezeWithSigner(magicWallet);

transaction = await transaction.signWithSigner(magicWallet);
const result = await transaction.executeWithSigner(magicWallet);
const receipt = await result.getReceiptWithSigner(magicWallet);

console.log(receipt.status.toString());

Compatibility

  • All Auth, User module methods
  • All EVM Provider functionality to respond to supported RPC methods
*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