How to use the @maticnetwork/maticjs.default function in @maticnetwork/maticjs

To help you get started, we’ve selected a few @maticnetwork/maticjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maticnetwork / matic.js / examples / node / approve-ERC20.js View on Github external
const bn = require('bn.js')

const Matic = require('@maticnetwork/maticjs').default
const config = require('./config')
const utils = require('./utils')

const token = config.ROPSTEN_TEST_TOKEN
const amount = new bn(1).mul(utils.SCALING_FACTOR)
const from = config.FROM_ADDRESS

// Create Matic object
const matic = new Matic({
  maticProvider: config.MATIC_PROVIDER,
  parentProvider: config.PARENT_PROVIDER,
  rootChain: config.ROOTCHAIN_ADDRESS,
  registry: config.REGISTRY_ADDRESS,
  depositManager: config.DEPOSITMANAGER_ADDRESS,
  withdrawManager: config.WITHDRAWMANAGER_ADDRESS,
})

async function execute() {
  await matic.initialize()
  matic.setWallet(config.PRIVATE_KEY)
  return matic.approveERC20TokensForDeposit(token, amount, { from })
}

async function executeRaw() { // eslint-disable-line
  await matic.initialize()
github maticnetwork / matic.js / examples / node / confirm-withdraw-ERC721.js View on Github external
const Matic = require('@maticnetwork/maticjs').default

const config = require('./config')

const from = config.FROM_ADDRESS // from address

// 0xbbaf7712bc426b665650992215f9c15ac9bda72bbb4e7d453ba9ed3875e0ebf5 ERC721 withdraw
var transactionHash = '0xbbaf7712bc426b665650992215f9c15ac9bda72bbb4e7d453ba9ed3875e0ebf5' // Insert txHash generated from initiate-withdraw.js

// Create object of Matic
const matic = new Matic({
   maticProvider: config.MATIC_PROVIDER,
   parentProvider: config.PARENT_PROVIDER,
   rootChain: config.ROOTCHAIN_ADDRESS,
   registry: config.REGISTRY_ADDRESS,
   depositManager: config.DEPOSITMANAGER_ADDRESS,
   withdrawManager: config.WITHDRAWMANAGER_ADDRESS,
})

matic.initialize().then(() => {
   matic.setWallet(config.PRIVATE_KEY)
   matic.withdrawNFT(transactionHash, {
      from,
   }).then((res) => {
      console.log(res) // eslint-disable-line
      // 0xebece1474592c1556b3389a1a76908b9bdfd4118e1d3f2e9308d6f1c5f173dd4
   })
github maticnetwork / matic.js / examples / node / process-exit.js View on Github external
const Matic = require('@maticnetwork/maticjs').default

const config = require('./config')

const from = config.FROM_ADDRESS // from address
const rootTokenAddress = config.PARENT_TEST_TOKEN // Root token address

// Create object of Matic
const matic = new Matic({
   maticProvider: config.MATIC_PROVIDER,
   parentProvider: config.PARENT_PROVIDER,
   rootChain: config.ROOTCHAIN_ADDRESS,
   registry: config.REGISTRY_ADDRESS,
   depositManager: config.DEPOSITMANAGER_ADDRESS,
   withdrawManager: config.WITHDRAWMANAGER_ADDRESS,
})

matic.initialize().then(() => {
   matic.setWallet(config.PRIVATE_KEY)
   matic.processExits(rootTokenAddress, {
      from,
   }).then((res) => {
      console.log(res) // eslint-disable-line
   })
})

@maticnetwork/maticjs

Javascript developer library for interacting with Matic Network

MIT
Latest version published 2 months ago

Package Health Score

82 / 100
Full package analysis

Popular @maticnetwork/maticjs functions