New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eth-merkle-bridge-js

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-merkle-bridge-js

Ethereum <-> Aergo Merkle Bridge JS SDK

  • 0.3.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

eth-merkle-bridge-js

JS SDK for Ethereum <-> Aergo Merkle bridge.

Quick start

npm i eth-merkle-bridge-js

Send Aergo ERC20 tokens by locking on Ethereum and Unfreezing on Aergo.

import {ethToAergo as eta} from 'eth-merkle-bridge-js';
import Web3 from 'web3';
import { AergoClient } from '@herajs/client';

// get providers to connect with networks
let web3 = new Web3(window.ethereum);
let accountId = await ethereum.enable();
web3.eth.defaultAccount = accountId[0];
let hera = new AergoClient(); // connect to localhost:7845 by default

// arguments
const bridgeEthAddr = "0x89eD1D1C145F6bF3A7e62d2B8eB0e1Bf15Cb2374";
const bridgeAergoAddr = "AmgQqVWX3JADRBEVkVCM4CyWdoeXuumeYGGJJxEeoAukRC26hxmw";
const aergoErc20Addr = "0xd898383A12CDE0eDF7642F7dD4D7006FdE5c433e";
const receiverAergoAddr = "AmNMFbiVsqy6vg4njsTjgy7bKPFHFYhLV4rzQyrENUS9AM1e3tw5";
const amount = "10000000000000000000" // 10 aergoErc20 with 18 decimals
let bridgeAergoAbi 
(async () => { bridgeAergoAbi = await hera.getABI(bridgeAergoAddr) })();


// LOCK TOKENS
// send any ERC20 from Ethereum to Aergo
const receipt = await eta.increaseApproval(
    web3, bridgeEthAddr, amount, aergoErc20Addr, erc20Abi);
const receipt = await eta.lock(
    web3, receiverAergoAddr, aergoErc20Addr, amount, bridgeEthAddr, 
    bridgeEthAbi
);

// Check unfreezable and pending balances
let [unfreezable, pending] = await eta.unfreezable(
    web3, hera, bridgeEthAddr, bridgeAergoAddr,
    receiverAergoAddr, aergoErc20Addr
);

// UNFREEZE TOKENS
// get aergo connect signer
const signer = await aergoConnectCall(
    'ACTIVE_ACCOUNT', 'AERGO_ACTIVE_ACCOUNT', {});
const txSender = signer.account.address;

// build unfreeze tx params
// metamask web3.eth provider doesn't implement getProof so use custom provider to query
let blockoWeb3 = new Web3("http://localhost:8545");
let builtTx = await eta.buildUnfreezeTx(
    blockoWeb3, hera, txSender, bridgeEthAddr, bridgeAergoAddr,
    bridgeAergoAbi, receiverAergoAddr, aergoErc20Addr
);
builtTx.to = bridgeAergoAddr;
builtTx.payload_json = JSON.parse(builtTx.payload);
delete builtTx.payload

// send built tx with aergo connect
const tx = await aergoConnectCall(
    'SEND_TX', 'AERGO_SEND_TX_RESULT', builtTx);
// then get tx receipt with tx.hash

Documentation

Aergo ERC20
Send aergo ERC20 from Ethereum to Aergo
  • ethToAergo.increaseApproval()
  • ethToAergo.lock()
  • ethToAergo.unfreezable()
  • ethToAergo.buildUnfreezeTx()
Send native(unfreezed) aergo from Aergo back to Ethereum (Erc20 form)
  • aergoToEth.buildFreezeTx()
  • aergoToEth.unlockable()
  • aergoToEth.unlock()
Other ERC20 tokens
Send ERC20 from Ethereum to Aergo
  • ethToAergo.increaseApproval()
  • ethToAergo.lock()
  • ethToAergo.mintable()
  • ethToAergo.buildMintTx()
Send minted token from Aergo back to Ethereum (Erc20 form)
  • aergoToEth.buildBurnTx()
  • aergoToEth.unlockable()
  • aergoToEth.unlock()
ARC1 Aergo native tokens
  • TODO
Utils
  • utils.getEthAnchorStatus()
  • utils.getAergoAnchorStatus()

Contribute

Setup
npm install
Test
npm test

FAQs

Package last updated on 06 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc