Skip to content

Instantly share code, notes, and snippets.

@anurag-arjun
Created January 10, 2019 11:37
Show Gist options
  • Select an option

  • Save anurag-arjun/c894e064f4f7f5a1e05da2c477851c27 to your computer and use it in GitHub Desktop.

Select an option

Save anurag-arjun/c894e064f4f7f5a1e05da2c477851c27 to your computer and use it in GitHub Desktop.
Depositing Funds from Kovan to Matic
const Matic = require('maticjs').default
const config = require('./config')
const token = '0x670568761764f53E6C10cd63b71024c31551c9EC' // test token address
const amount = '10000000000000000' // amount in wei (0.01 TEST)
const from = '0xdcd53258BA8A69C6a505300BE75447A772bFd3d6' // from address
// Create object of Matic
const matic = new Matic({
maticProvider: config.MATIC_PROVIDER,
parentProvider: config.PARENT_PROVIDER,
rootChainAddress: config.ROOTCHAIN_ADDRESS,
syncerUrl: config.SYNCER_URL,
watcherUrl: config.WATCHER_URL,
})
matic.wallet = '0x' + config.PRIVATE_KEY // prefix with `0x`
// Approve token from your account to the Matic contracts
matic
.approveTokensForDeposit(token, amount, {
from,
onTransactionHash: () => {
// action on Transaction success
console.log("Deposit Tokens from Kovan/Ethereum to Matic - Transaction Approved.")
},
})
.then(() => {
// Deposit tokens
matic.
depositTokens(token, from, amount, {
from,
onTransactionHash: () => {
// action on Transaction success
console.log("Tokens deposited from Kovan/Ethereum to Matic.")
},
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment